Skip to content

Commit cff448b

Browse files
Merge pull request #13357 from Romain-Geissler-1A/backport-connection-implies-remote
Option --url and --connection should imply --remote.
2 parents 49d511b + ca980c2 commit cff448b

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

cmd/podman/registry/remote.go

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ func IsRemote() bool {
3030
fs.Usage = func() {}
3131
fs.SetInterspersed(false)
3232
fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", remote, "")
33+
connectionFlagName := "connection"
34+
ignoredConnection := ""
35+
fs.StringVarP(&ignoredConnection, connectionFlagName, "c", "", "")
36+
urlFlagName := "url"
37+
ignoredURL := ""
38+
fs.StringVar(&ignoredURL, urlFlagName, "", "")
3339

3440
// The shell completion logic will call a command called "__complete" or "__completeNoDesc"
3541
// This command will always be the second argument
@@ -39,6 +45,8 @@ func IsRemote() bool {
3945
start = 2
4046
}
4147
_ = fs.Parse(os.Args[start:])
48+
// --connection or --url implies --remote
49+
remoteFromCLI.Value = remoteFromCLI.Value || fs.Changed(connectionFlagName) || fs.Changed(urlFlagName)
4250
})
4351
return podmanOptions.EngineMode == entities.TunnelMode || remoteFromCLI.Value
4452
}

docs/source/markdown/podman.1.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ and "$graphroot/networks" as rootless.
4242

4343
#### **--connection**, **-c**
4444
Connection to use for remote podman, including Mac and Windows (excluding WSL2) machines, (Default connection is configured in `containers.conf`)
45+
Setting this option will switch the **--remote** option to true.
4546
Remote connections use local containers.conf for default.
4647

4748
#### **--conmon**
@@ -108,6 +109,7 @@ environment variable is set, the **--remote** option defaults to true.
108109

109110
#### **--url**=*value*
110111
URL to access Podman service (default from `containers.conf`, rootless `unix://run/user/$UID/podman/podman.sock` or as root `unix://run/podman/podman.sock`).
112+
Setting this option will switch the **--remote** option to true.
111113

112114
- `CONTAINER_HOST` is of the format `<schema>://[<user[:<password>]@]<host>[:<port>][<path>]`
113115

test/system/001-basic.bats

+11
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ See 'podman version --help'" "podman version --remote"
126126
if grep -- " --remote " <<<"$output"; then
127127
die "podman --help, with CONTAINER_CONNECTION set, is showing --remote"
128128
fi
129+
130+
# When it detects --url or --connection, --remote is not an option
131+
run_podman --url foobar --help
132+
if grep -- " --remote " <<<"$output"; then
133+
die "podman --help, with --url set, is showing --remote"
134+
fi
135+
136+
run_podman --connection foobar --help
137+
if grep -- " --remote " <<<"$output"; then
138+
die "podman --help, with --connection set, is showing --remote"
139+
fi
129140
}
130141

131142
# Check that just calling "podman-remote" prints the usage message even

0 commit comments

Comments
 (0)