Skip to content

Commit

Permalink
Merge pull request #14947 from rhatdan/root
Browse files Browse the repository at this point in the history
Add --host and -H as equivalent options to --url
  • Loading branch information
openshift-ci[bot] authored Jul 18, 2022
2 parents 5201ea8 + 18c0c19 commit d890c4d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/podman/registry/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func IsRemote() bool {
fs.SetInterspersed(false)
fs.BoolVarP(&remoteFromCLI.Value, "remote", "r", remote, "")
connectionFlagName := "connection"
ignoredConnection := ""
fs.StringVarP(&ignoredConnection, connectionFlagName, "c", "", "")
fs.StringP(connectionFlagName, "c", "", "")
hostFlagName := "host"
fs.StringP(hostFlagName, "H", "", "")
urlFlagName := "url"
ignoredURL := ""
fs.StringVar(&ignoredURL, urlFlagName, "", "")
fs.String(urlFlagName, "", "")

// The shell completion logic will call a command called "__complete" or "__completeNoDesc"
// This command will always be the second argument
Expand All @@ -46,7 +46,7 @@ func IsRemote() bool {
}
_ = fs.Parse(os.Args[start:])
// --connection or --url implies --remote
remoteFromCLI.Value = remoteFromCLI.Value || fs.Changed(connectionFlagName) || fs.Changed(urlFlagName)
remoteFromCLI.Value = remoteFromCLI.Value || fs.Changed(connectionFlagName) || fs.Changed(urlFlagName) || fs.Changed(hostFlagName)
})
return podmanOptions.EngineMode == entities.TunnelMode || remoteFromCLI.Value
}
2 changes: 2 additions & 0 deletions cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
urlFlagName := "url"
lFlags.StringVar(&opts.URI, urlFlagName, uri, "URL to access Podman service (CONTAINER_HOST)")
_ = cmd.RegisterFlagCompletionFunc(urlFlagName, completion.AutocompleteDefault)
lFlags.StringVarP(&opts.URI, "host", "H", uri, "Used for Docker compatibility")
_ = lFlags.MarkHidden("host")

// Context option added just for compatibility with DockerCLI.
lFlags.String("context", "default", "Name of the context to use to connect to the daemon (This flag is a NOOP and provided solely for scripting compatibility.)")
Expand Down
19 changes: 19 additions & 0 deletions test/system/250-systemd.bats
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,23 @@ EOF
run_podman rm -f -t 0 $cname
}

@test "podman-system-service containers --host" {
skip_if_remote "N/A under podman-remote"

SERVICE_NAME=podman-service-$(random_string)
port=$(random_free_port)
URL=tcp://127.0.0.1:$port

systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0
wait_for_port 127.0.0.1 $port

run_podman --host $URL run --rm $IMAGE true
run_podman -H $URL run --rm $IMAGE true

systemctl stop $SERVICE_NAME

# Make sure the option is actually connecting
run_podman 125 --host $URL run --rm $IMAGE true
assert "$output" =~ "Cannot connect to Podman.*connection refused"
}
# vim: filetype=sh

0 comments on commit d890c4d

Please sign in to comment.