summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-10-16 14:29:40 +0200
committerGitHub <noreply@github.com>2021-10-16 14:29:40 +0200
commit0144f46ac5067196019225430847691502d74da7 (patch)
tree49b7f0c94eaf360c1612befff2f5cd5fd6b5c92f /cmd
parent171f7b8975194ff9f47a3dd23adec81d11e6d104 (diff)
parent468e7c689b718229ed062b3daae9373f7459b6e2 (diff)
downloadpodman-0144f46ac5067196019225430847691502d74da7.tar.gz
podman-0144f46ac5067196019225430847691502d74da7.tar.bz2
podman-0144f46ac5067196019225430847691502d74da7.zip
Merge pull request #11990 from rhatdan/remote
Move CONTAINER_HOST and _CONNECTION to IsRemote Function
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/registry/remote.go8
-rw-r--r--cmd/podman/root.go10
2 files changed, 8 insertions, 10 deletions
diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go
index b5da98bd4..c78930574 100644
--- a/cmd/podman/registry/remote.go
+++ b/cmd/podman/registry/remote.go
@@ -19,11 +19,17 @@ var remoteFromCLI = struct {
// Use in init() functions as an initialization check
func IsRemote() bool {
remoteFromCLI.sync.Do(func() {
+ remote := false
+ if _, ok := os.LookupEnv("CONTAINER_HOST"); ok {
+ remote = true
+ } else if _, ok := os.LookupEnv("CONTAINER_CONNECTION"); ok {
+ remote = true
+ }
fs := pflag.NewFlagSet("remote", pflag.ContinueOnError)
fs.ParseErrorsWhitelist.UnknownFlags = true
fs.Usage = func() {}
fs.SetInterspersed(false)
- fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", false, "")
+ fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", remote, "")
// The shell completion logic will call a command called "__complete" or "__completeNoDesc"
// This command will always be the second argument
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 734636646..6da34050e 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -314,15 +314,7 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
lFlags.StringVar(&opts.Identity, identityFlagName, ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
_ = cmd.RegisterFlagCompletionFunc(identityFlagName, completion.AutocompleteDefault)
- remote := false
- if env, ok := os.LookupEnv("CONTAINER_HOST"); ok {
- logrus.Infof("CONTAINER_HOST==%q, defaulting to '--remote=true'", env)
- remote = true
- } else if env, ok := os.LookupEnv("CONTAINER_CONNECTION"); ok {
- logrus.Infof("CONTAINER_CONNECTION==%q, defaulting to '--remote=true'", env)
- remote = true
- }
- lFlags.BoolVarP(&opts.Remote, "remote", "r", remote, "Access remote Podman service")
+ lFlags.BoolVarP(&opts.Remote, "remote", "r", registry.IsRemote(), "Access remote Podman service")
pFlags := cmd.PersistentFlags()
if registry.IsRemote() {
if err := lFlags.MarkHidden("remote"); err != nil {