diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-30 13:02:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-30 13:02:41 -0400 |
commit | d87e26ec76ef849f734e461ed158c0d252135eac (patch) | |
tree | 31e947a4fa4fc9561b9d367852ec99cdf95a8886 /cmd/podman/registry | |
parent | 3ae1cd806c9125e48af08368e488ea39cd28256d (diff) | |
parent | b64d29bdf2d6aa9fe402ab2b54cc888fe1e4eb62 (diff) | |
download | podman-d87e26ec76ef849f734e461ed158c0d252135eac.tar.gz podman-d87e26ec76ef849f734e461ed158c0d252135eac.tar.bz2 podman-d87e26ec76ef849f734e461ed158c0d252135eac.zip |
Merge pull request #7502 from Luap99/v2.0-remote
V2.0: Futher --remote flag backports
Diffstat (limited to 'cmd/podman/registry')
-rw-r--r-- | cmd/podman/registry/remote.go | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go index 006a1b900..217652ec0 100644 --- a/cmd/podman/registry/remote.go +++ b/cmd/podman/registry/remote.go @@ -5,22 +5,25 @@ import ( "sync" "github.com/containers/libpod/v2/pkg/domain/entities" - "github.com/spf13/cobra" + "github.com/spf13/pflag" ) -var ( - // Was --remote given on command line - remoteOverride bool - remoteSync sync.Once -) +// Value for --remote given on command line +var remoteFromCLI = struct { + Value bool + sync sync.Once +}{} -// IsRemote returns true if podman was built to run remote -// Use in init() functions as a initialization check +// IsRemote returns true if podman was built to run remote or --remote flag given on CLI +// Use in init() functions as an initialization check func IsRemote() bool { - remoteSync.Do(func() { - remote := &cobra.Command{} - remote.Flags().BoolVarP(&remoteOverride, "remote", "r", false, "") - _ = remote.ParseFlags(os.Args) + remoteFromCLI.sync.Do(func() { + fs := pflag.NewFlagSet("remote", pflag.ContinueOnError) + fs.ParseErrorsWhitelist.UnknownFlags = true + fs.Usage = func() {} + fs.SetInterspersed(false) + fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", false, "") + _ = fs.Parse(os.Args[1:]) }) - return podmanOptions.EngineMode == entities.TunnelMode || remoteOverride + return podmanOptions.EngineMode == entities.TunnelMode || remoteFromCLI.Value } |