diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-06-22 14:29:04 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-06-26 17:09:24 -0700 |
commit | 6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4 (patch) | |
tree | ab64703869f9300d486531f5781d825e2d9aaec7 /cmd/podman/registry | |
parent | 673116c063f173ae7ff799a920f9c1ca28194b9d (diff) | |
download | podman-6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4.tar.gz podman-6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4.tar.bz2 podman-6fb5f01c736d5cbf11bc7eaad09f6f0c7fd1d0d4.zip |
Fixes --remote flag issues
* --remote, --url and --identity are now anchored to podman command.
Subcommands should no longer have issues
* TraverseChildren now set to V1 expectations
* Latest flag now has helper function. Now has consistent usage.
* IsRemote() uses cobra parser to determin if --remote is given
* Moved validation functions from parser pkg to validate pkg
*
Fixes #6598
Fixes #6704
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/registry')
-rw-r--r-- | cmd/podman/registry/config.go | 16 | ||||
-rw-r--r-- | cmd/podman/registry/remote.go | 19 |
2 files changed, 19 insertions, 16 deletions
diff --git a/cmd/podman/registry/config.go b/cmd/podman/registry/config.go index a67568d73..85a63402b 100644 --- a/cmd/podman/registry/config.go +++ b/cmd/podman/registry/config.go @@ -5,7 +5,6 @@ import ( "os" "path/filepath" "runtime" - "strings" "sync" "github.com/containers/common/pkg/config" @@ -45,7 +44,7 @@ func newPodmanConfig() { case "linux": // Some linux clients might only be compiled without ABI // support (e.g., podman-remote). - if abiSupport { + if abiSupport && !remoteOverride { mode = entities.ABIMode } else { mode = entities.TunnelMode @@ -55,19 +54,6 @@ func newPodmanConfig() { os.Exit(1) } - // Check if need to fallback to the tunnel mode if --remote is used. - if abiSupport && mode == entities.ABIMode { - // cobra.Execute() may not be called yet, so we peek at os.Args. - for _, v := range os.Args { - // Prefix checking works because of how default EngineMode's - // have been defined. - if strings.HasPrefix(v, "--remote") { - mode = entities.TunnelMode - break - } - } - } - cfg, err := config.NewConfig("") if err != nil { fmt.Fprint(os.Stderr, "Failed to obtain podman configuration: "+err.Error()) diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go index 95870750e..ed1a874d6 100644 --- a/cmd/podman/registry/remote.go +++ b/cmd/podman/registry/remote.go @@ -1,9 +1,26 @@ package registry import ( + "os" + "sync" + "github.com/containers/libpod/pkg/domain/entities" + "github.com/spf13/cobra" +) + +var ( + // Was --remote given on command line + remoteOverride bool + remoteSync sync.Once ) +// IsRemote returns true if podman was built to run remote +// Use in init() functions as a initialization check func IsRemote() bool { - return podmanOptions.EngineMode == entities.TunnelMode + remoteSync.Do(func() { + remote := &cobra.Command{} + remote.Flags().BoolVarP(&remoteOverride, "remote", "r", false, "") + _ = remote.ParseFlags(os.Args) + }) + return podmanOptions.EngineMode == entities.TunnelMode || remoteOverride } |