From 6d2f0857171d560d8715699b3cff82e068256518 Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Mon, 18 May 2020 14:58:03 +0200 Subject: [PATCH] Do not pass global flags to context show Signed-off-by: Christopher Crone --- cli/cmd/context/context.go | 2 +- cli/cmd/context/show.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cli/cmd/context/context.go b/cli/cmd/context/context.go index 441e507a..26edb363 100644 --- a/cli/cmd/context/context.go +++ b/cli/cmd/context/context.go @@ -46,7 +46,7 @@ func Command(opts *cliopts.GlobalOpts) *cobra.Command { createCommand(), listCommand(), removeCommand(), - showCommand(opts), + showCommand(), useCommand(opts), login.Command(), ) diff --git a/cli/cmd/context/show.go b/cli/cmd/context/show.go index 54f4bd50..20e4aec9 100644 --- a/cli/cmd/context/show.go +++ b/cli/cmd/context/show.go @@ -33,27 +33,26 @@ import ( "github.com/spf13/cobra" - cliopts "github.com/docker/api/cli/options" apicontext "github.com/docker/api/context" "github.com/docker/api/context/store" ) -func showCommand(opts *cliopts.GlobalOpts) *cobra.Command { +func showCommand() *cobra.Command { return &cobra.Command{ Use: "show", Short: "Print the current context", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return runShow(cmd.Context(), opts) + return runShow(cmd.Context()) }, } } -func runShow(ctx context.Context, opts *cliopts.GlobalOpts) error { - s := store.ContextStore(ctx) +func runShow(ctx context.Context) error { name := apicontext.CurrentContext(ctx) // Match behavior of existing CLI if name != store.DefaultContextName { + s := store.ContextStore(ctx) if _, err := s.Get(name, nil); err != nil { return err }