Merge pull request #3886 from thaJeztah/context_lazy_evaluate_step3

cli/command/context: "docker context show": don't validate context
This commit is contained in:
Sebastiaan van Stijn 2022-11-28 11:52:32 +01:00 committed by GitHub
commit 81c68913e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 11 deletions

View File

@ -16,19 +16,14 @@ func newShowCommand(dockerCli command.Cli) *cobra.Command {
Short: "Print the name of the current context", Short: "Print the name of the current context",
Args: cli.NoArgs, Args: cli.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return runShow(dockerCli) runShow(dockerCli)
return nil
}, },
ValidArgsFunction: completion.NoComplete, ValidArgsFunction: completion.NoComplete,
} }
return cmd return cmd
} }
func runShow(dockerCli command.Cli) error { func runShow(dockerCli command.Cli) {
context := dockerCli.CurrentContext() fmt.Fprintln(dockerCli.Out(), dockerCli.CurrentContext())
metadata, err := dockerCli.ContextStore().GetMetadata(context)
if err != nil {
return err
}
fmt.Fprintln(dockerCli.Out(), metadata.Name)
return nil
} }

View File

@ -3,7 +3,6 @@ package context
import ( import (
"testing" "testing"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -13,6 +12,6 @@ func TestShow(t *testing.T) {
cli.SetCurrentContext("current") cli.SetCurrentContext("current")
cli.OutBuffer().Reset() cli.OutBuffer().Reset()
assert.NilError(t, runShow(cli)) runShow(cli)
golden.Assert(t, cli.OutBuffer().String(), "show.golden") golden.Assert(t, cli.OutBuffer().String(), "show.golden")
} }