From 1bb2909d1a8a2a3988373c91c949e6d1c6baf7f9 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Wed, 17 Jun 2020 22:20:23 +0200 Subject: [PATCH] Do not restrict `docker inspect` to 1 arg, can be zero (inspect current context), one or several. Especially, inspect with zero param is already used by VSCode. Cf https://github.com/docker/desktop-microsoft/issues/19 --- cli/cmd/context/inspect.go | 4 +++- tests/e2e/e2e_test.go | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/cmd/context/inspect.go b/cli/cmd/context/inspect.go index 5ce3cdc4..0a7be9c0 100644 --- a/cli/cmd/context/inspect.go +++ b/cli/cmd/context/inspect.go @@ -37,10 +37,12 @@ func inspectCommand() *cobra.Command { cmd := &cobra.Command{ Use: "inspect", Short: "Display detailed information on one or more contexts", - Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return mobycli.ExecCmd(cmd) }, } + // flags matching delegated command in moby cli + flags := cmd.Flags() + flags.StringP("format", "f", "", "Format the output using the given Go template") return cmd } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 62f223b7..2e56bf72 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -79,6 +79,11 @@ func (s *E2eSuite) TestInspectDefaultContext() { Expect(output).To(ContainSubstring(`"Name": "default"`)) } +func (s *E2eSuite) TestInspectContextNoArgs() { + output := s.NewDockerCommand("context", "inspect").ExecOrDie() + Expect(output).To(ContainSubstring(`"Name": "default"`)) +} + func (s *E2eSuite) TestContextCreateParseErrorDoesNotDelegateToLegacy() { It("should dispay new cli error when parsing context create flags", func() { _, err := s.NewDockerCommand("context", "create", "aci", "--subscription-id", "titi").Exec()