mirror of https://github.com/docker/compose.git
Add "*" for the current context
This commit is contained in:
parent
cf1be96833
commit
0bd18986dd
|
@ -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()
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Reference in New Issue