diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-03-23 10:27:32 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-03-24 11:03:13 -0700 |
commit | 77a2af8817284d134ea1f30f0b06291a5b05c5a0 (patch) | |
tree | f6ed82f9c435c30b44d5c820502607ba60e89282 /cmd/podmanV2/registry | |
parent | c29a4c69044c02eee564fc72c64144b2a76d1d73 (diff) | |
download | podman-77a2af8817284d134ea1f30f0b06291a5b05c5a0.tar.gz podman-77a2af8817284d134ea1f30f0b06291a5b05c5a0.tar.bz2 podman-77a2af8817284d134ea1f30f0b06291a5b05c5a0.zip |
Combine GlobalFlags and EngineFlags into EngineOptions
* EngineOptions obtained in command via
`opt, err := registry.Options(cmd)`
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podmanV2/registry')
-rw-r--r-- | cmd/podmanV2/registry/registry.go | 28 | ||||
-rw-r--r-- | cmd/podmanV2/registry/remote.go | 9 |
2 files changed, 31 insertions, 6 deletions
diff --git a/cmd/podmanV2/registry/registry.go b/cmd/podmanV2/registry/registry.go index b0c11ba04..9c12b2456 100644 --- a/cmd/podmanV2/registry/registry.go +++ b/cmd/podmanV2/registry/registry.go @@ -1,6 +1,8 @@ package registry import ( + "context" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/domain/infra" @@ -20,8 +22,7 @@ var ( imageEngine entities.ImageEngine containerEngine entities.ContainerEngine - EngineOpts entities.EngineOptions - GlobalFlags entities.EngineFlags + EngineOptions entities.EngineOptions ExitCode = define.ExecErrorCodeGeneric ) @@ -76,8 +77,8 @@ func ImageEngine() entities.ImageEngine { // NewImageEngine is a wrapper for building an ImageEngine to be used for PreRunE functions func NewImageEngine(cmd *cobra.Command, args []string) (entities.ImageEngine, error) { if imageEngine == nil { - EngineOpts.FlagSet = cmd.Flags() - engine, err := infra.NewImageEngine(EngineOpts) + EngineOptions.FlagSet = cmd.Flags() + engine, err := infra.NewImageEngine(EngineOptions) if err != nil { return nil, err } @@ -93,8 +94,8 @@ func ContainerEngine() entities.ContainerEngine { // NewContainerEngine is a wrapper for building an ContainerEngine to be used for PreRunE functions func NewContainerEngine(cmd *cobra.Command, args []string) (entities.ContainerEngine, error) { if containerEngine == nil { - EngineOpts.FlagSet = cmd.Flags() - engine, err := infra.NewContainerEngine(EngineOpts) + EngineOptions.FlagSet = cmd.Flags() + engine, err := infra.NewContainerEngine(EngineOptions) if err != nil { return nil, err } @@ -109,3 +110,18 @@ func SubCommandExists(cmd *cobra.Command, args []string) error { } return errors.Errorf("missing command '%[1]s COMMAND'\nTry '%[1]s --help' for more information.", cmd.CommandPath()) } + +type podmanContextKey string + +var podmanFactsKey = podmanContextKey("engineOptions") + +func NewOptions(ctx context.Context, facts *entities.EngineOptions) context.Context { + return context.WithValue(ctx, podmanFactsKey, facts) +} + +func Options(cmd *cobra.Command) (*entities.EngineOptions, error) { + if f, ok := cmd.Context().Value(podmanFactsKey).(*entities.EngineOptions); ok { + return f, errors.New("Command Context ") + } + return nil, nil +} diff --git a/cmd/podmanV2/registry/remote.go b/cmd/podmanV2/registry/remote.go new file mode 100644 index 000000000..32a231ac4 --- /dev/null +++ b/cmd/podmanV2/registry/remote.go @@ -0,0 +1,9 @@ +package registry + +import ( + "github.com/containers/libpod/pkg/domain/entities" +) + +func IsRemote() bool { + return EngineOptions.EngineMode == entities.TunnelMode +} |