diff --git a/cli/cmd/context/ls.go b/cli/cmd/context/ls.go index 192a3e43..569fce52 100644 --- a/cli/cmd/context/ls.go +++ b/cli/cmd/context/ls.go @@ -35,6 +35,7 @@ import ( "github.com/spf13/cobra" + apicontext "github.com/docker/api/context" "github.com/docker/api/context/store" ) @@ -52,6 +53,7 @@ func listCommand() *cobra.Command { } func runList(ctx context.Context) error { + currentContext := apicontext.CurrentContext(ctx) s := store.ContextStore(ctx) contexts, err := s.List() if err != nil { @@ -63,7 +65,11 @@ func runList(ctx context.Context) error { format := "%s\t%s\t%s\n" for _, c := range contexts { - fmt.Fprintf(w, format, c.Name, c.Metadata.Description, c.Metadata.Type) + contextName := c.Name + if c.Name == currentContext { + contextName += " *" + } + fmt.Fprintf(w, format, contextName, c.Metadata.Description, c.Metadata.Type) } return w.Flush() diff --git a/tests/e2e/e2e.go b/tests/e2e/e2e.go index 1b577dd5..a5e7f8d4 100644 --- a/tests/e2e/e2e.go +++ b/tests/e2e/e2e.go @@ -59,7 +59,7 @@ func main() { It("uses the test context", func() { currentContext := NewDockerCommand("context", "use", "test-example").ExecOrDie() Expect(currentContext).To(ContainSubstring("test-example")) - output := NewCommand("docker", "context", "ls").ExecOrDie() + output := NewDockerCommand("context", "ls").ExecOrDie() Expect(output).To(ContainSubstring("test-example *")) output = NewDockerCommand("context", "show").ExecOrDie() Expect(output).To(ContainSubstring("test-example"))