Skip to content

Commit

Permalink
Merge pull request #9907 from rhatdan/options
Browse files Browse the repository at this point in the history
Add support for podman --context default
  • Loading branch information
openshift-merge-robot authored Apr 5, 2021
2 parents ca095e4 + c6a21a3 commit e9e4898
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
os.Setenv("TMPDIR", "/var/tmp")
}

context := cmd.Root().LocalFlags().Lookup("context")
if context.Value.String() != "default" {
return errors.New("Podman does not support swarm, the only --context value allowed is \"default\"")
}
if !registry.IsRemote() {
if cmd.Flag("cpu-profile").Changed {
f, err := os.Create(cfg.CPUProfile)
Expand Down Expand Up @@ -269,6 +273,10 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
lFlags.StringVar(&opts.URI, urlFlagName, uri, "URL to access Podman service (CONTAINER_HOST)")
_ = cmd.RegisterFlagCompletionFunc(urlFlagName, completion.AutocompleteDefault)

// 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.)")
_ = lFlags.MarkHidden("context")

identityFlagName := "identity"
lFlags.StringVar(&opts.Identity, identityFlagName, ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
_ = cmd.RegisterFlagCompletionFunc(identityFlagName, completion.AutocompleteDefault)
Expand Down
7 changes: 7 additions & 0 deletions test/system/001-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ function setup() {
:
}

@test "podman --context emits reasonable output" {
run_podman 125 --context=swarm version
is "$output" "Error: Podman does not support swarm, the only --context value allowed is \"default\"" "--context=default or fail"

run_podman --context=default version
}

@test "podman version emits reasonable output" {
run_podman version

Expand Down

0 comments on commit e9e4898

Please sign in to comment.