Skip to content

Commit

Permalink
Merge pull request #3886 from thaJeztah/context_lazy_evaluate_step3
Browse files Browse the repository at this point in the history
cli/command/context: "docker context show": don't validate context
  • Loading branch information
thaJeztah authored Nov 28, 2022
2 parents ba501a4 + 6ba7de3 commit 81c6891
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 4 additions & 9 deletions cli/command/context/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ func newShowCommand(dockerCli command.Cli) *cobra.Command {
Short: "Print the name of the current context",
Args: cli.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return runShow(dockerCli)
runShow(dockerCli)
return nil
},
ValidArgsFunction: completion.NoComplete,
}
return cmd
}

func runShow(dockerCli command.Cli) error {
context := dockerCli.CurrentContext()
metadata, err := dockerCli.ContextStore().GetMetadata(context)
if err != nil {
return err
}
fmt.Fprintln(dockerCli.Out(), metadata.Name)
return nil
func runShow(dockerCli command.Cli) {
fmt.Fprintln(dockerCli.Out(), dockerCli.CurrentContext())
}
3 changes: 1 addition & 2 deletions cli/command/context/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package context
import (
"testing"

"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)

Expand All @@ -13,6 +12,6 @@ func TestShow(t *testing.T) {
cli.SetCurrentContext("current")

cli.OutBuffer().Reset()
assert.NilError(t, runShow(cli))
runShow(cli)
golden.Assert(t, cli.OutBuffer().String(), "show.golden")
}

0 comments on commit 81c6891

Please sign in to comment.