From 84d47b544e49ca7d268bdad108592d3f1b6a3504 Mon Sep 17 00:00:00 2001 From: Silvin Lubecki Date: Mon, 18 Jan 2021 11:43:29 +0100 Subject: [PATCH] Add "json" as default value to format flag in all inspect commands. Signed-off-by: Silvin Lubecki Signed-off-by: Sebastiaan van Stijn --- cli/command/config/inspect.go | 3 ++- cli/command/container/inspect.go | 3 ++- cli/command/context/inspect.go | 3 ++- cli/command/image/inspect.go | 3 ++- cli/command/network/inspect.go | 3 ++- cli/command/node/inspect.go | 3 ++- cli/command/plugin/inspect.go | 3 ++- cli/command/secret/inspect.go | 3 ++- cli/command/service/inspect.go | 3 ++- cli/command/system/inspect.go | 3 ++- cli/command/volume/inspect.go | 3 ++- cli/flags/common.go | 5 +++++ docs/reference/commandline/config_inspect.md | 6 +++++- docs/reference/commandline/context_inspect.md | 5 ++++- docs/reference/commandline/network_inspect.md | 6 +++++- docs/reference/commandline/node_inspect.md | 7 +++++-- docs/reference/commandline/plugin_inspect.md | 5 ++++- docs/reference/commandline/secret_inspect.md | 6 +++++- docs/reference/commandline/service_inspect.md | 7 +++++-- docs/reference/commandline/volume_inspect.md | 5 ++++- 20 files changed, 64 insertions(+), 21 deletions(-) diff --git a/cli/command/config/inspect.go b/cli/command/config/inspect.go index cb39ce2799..ddce83fd7a 100644 --- a/cli/command/config/inspect.go +++ b/cli/command/config/inspect.go @@ -8,6 +8,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/formatter" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -30,7 +31,7 @@ func newConfigInspectCommand(dockerCli command.Cli) *cobra.Command { }, } - cmd.Flags().StringVarP(&opts.Format, "format", "f", "", "Format the output using the given Go template") + cmd.Flags().StringVarP(&opts.Format, "format", "f", "json", flagsHelper.InspectFormatHelp) cmd.Flags().BoolVar(&opts.Pretty, "pretty", false, "Print the information in a human friendly format") return cmd } diff --git a/cli/command/container/inspect.go b/cli/command/container/inspect.go index 4f50e2a080..168740fae0 100644 --- a/cli/command/container/inspect.go +++ b/cli/command/container/inspect.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -30,7 +31,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes") return cmd diff --git a/cli/command/context/inspect.go b/cli/command/context/inspect.go index 2145845a7a..246436c1ca 100644 --- a/cli/command/context/inspect.go +++ b/cli/command/context/inspect.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" "github.com/docker/cli/cli/context/store" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -34,7 +35,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) return cmd } diff --git a/cli/command/image/inspect.go b/cli/command/image/inspect.go index 2044fcafdf..e08b5fc3d9 100644 --- a/cli/command/image/inspect.go +++ b/cli/command/image/inspect.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -29,7 +30,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) return cmd } diff --git a/cli/command/network/inspect.go b/cli/command/network/inspect.go index 3d7543d9eb..890ac77506 100644 --- a/cli/command/network/inspect.go +++ b/cli/command/network/inspect.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/docker/api/types" "github.com/spf13/cobra" ) @@ -29,7 +30,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { }, } - cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + cmd.Flags().StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) cmd.Flags().BoolVarP(&opts.verbose, "verbose", "v", false, "Verbose output for diagnostics") return cmd diff --git a/cli/command/node/inspect.go b/cli/command/node/inspect.go index 9c68f43b79..51f7c50e1d 100644 --- a/cli/command/node/inspect.go +++ b/cli/command/node/inspect.go @@ -8,6 +8,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/formatter" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -31,7 +32,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) flags.BoolVar(&opts.pretty, "pretty", false, "Print the information in a human friendly format") return cmd } diff --git a/cli/command/plugin/inspect.go b/cli/command/plugin/inspect.go index 9ce49eb908..baf166fccf 100644 --- a/cli/command/plugin/inspect.go +++ b/cli/command/plugin/inspect.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -28,7 +29,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) return cmd } diff --git a/cli/command/secret/inspect.go b/cli/command/secret/inspect.go index f7866de1bf..05962b9a8b 100644 --- a/cli/command/secret/inspect.go +++ b/cli/command/secret/inspect.go @@ -8,6 +8,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/formatter" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -29,7 +30,7 @@ func newSecretInspectCommand(dockerCli command.Cli) *cobra.Command { }, } - cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + cmd.Flags().StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) cmd.Flags().BoolVar(&opts.pretty, "pretty", false, "Print the information in a human friendly format") return cmd } diff --git a/cli/command/service/inspect.go b/cli/command/service/inspect.go index 38709963a1..a06149ec01 100644 --- a/cli/command/service/inspect.go +++ b/cli/command/service/inspect.go @@ -7,6 +7,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/formatter" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/docker/api/types" apiclient "github.com/docker/docker/client" "github.com/pkg/errors" @@ -37,7 +38,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) flags.BoolVar(&opts.pretty, "pretty", false, "Print the information in a human friendly format") return cmd } diff --git a/cli/command/system/inspect.go b/cli/command/system/inspect.go index b49b4b33d3..56199aecde 100644 --- a/cli/command/system/inspect.go +++ b/cli/command/system/inspect.go @@ -8,6 +8,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/docker/api/types" apiclient "github.com/docker/docker/client" "github.com/pkg/errors" @@ -36,7 +37,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command { } flags := cmd.Flags() - flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + flags.StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) flags.StringVar(&opts.inspectType, "type", "", "Return JSON for specified type") flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes if the type is container") diff --git a/cli/command/volume/inspect.go b/cli/command/volume/inspect.go index 52cfb0f0a9..3d3887635e 100644 --- a/cli/command/volume/inspect.go +++ b/cli/command/volume/inspect.go @@ -6,6 +6,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/inspect" + flagsHelper "github.com/docker/cli/cli/flags" "github.com/spf13/cobra" ) @@ -27,7 +28,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { }, } - cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + cmd.Flags().StringVarP(&opts.format, "format", "f", "json", flagsHelper.InspectFormatHelp) return cmd } diff --git a/cli/flags/common.go b/cli/flags/common.go index cf2ccb59a8..f692af75f7 100644 --- a/cli/flags/common.go +++ b/cli/flags/common.go @@ -21,6 +21,11 @@ const ( DefaultCertFile = "cert.pem" // FlagTLSVerify is the flag name for the TLS verification option FlagTLSVerify = "tlsverify" + // InspectFormatHelp describes the --format flag behavior for inspect commands + InspectFormatHelp = `Format output using a custom template: +'json': Print in JSON format +'TEMPLATE': Print output using the given Go template. +Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates` ) var ( diff --git a/docs/reference/commandline/config_inspect.md b/docs/reference/commandline/config_inspect.md index a2cf767ec5..1d8022bbbf 100644 --- a/docs/reference/commandline/config_inspect.md +++ b/docs/reference/commandline/config_inspect.md @@ -12,7 +12,11 @@ Usage: docker config inspect [OPTIONS] CONFIG [CONFIG...] Display detailed information on one or more configs Options: - -f, --format string Format the output using the given Go template + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") + --pretty Print the information in a human friendly format --help Print usage ``` diff --git a/docs/reference/commandline/context_inspect.md b/docs/reference/commandline/context_inspect.md index 0b86829a9b..6d038b428f 100644 --- a/docs/reference/commandline/context_inspect.md +++ b/docs/reference/commandline/context_inspect.md @@ -12,7 +12,10 @@ Usage: docker context inspect [OPTIONS] [CONTEXT] [CONTEXT...] Display detailed information on one or more contexts Options: - -f, --format string Format the output using the given Go template + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") ``` ## Description diff --git a/docs/reference/commandline/network_inspect.md b/docs/reference/commandline/network_inspect.md index 365ad13430..2c0150253a 100644 --- a/docs/reference/commandline/network_inspect.md +++ b/docs/reference/commandline/network_inspect.md @@ -12,7 +12,11 @@ Usage: docker network inspect [OPTIONS] NETWORK [NETWORK...] Display detailed information on one or more networks Options: - -f, --format string Format the output using the given Go template + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") + -v, --verbose Verbose output for diagnostics --help Print usage ``` diff --git a/docs/reference/commandline/node_inspect.md b/docs/reference/commandline/node_inspect.md index 7f479046a4..0ac4289909 100644 --- a/docs/reference/commandline/node_inspect.md +++ b/docs/reference/commandline/node_inspect.md @@ -12,9 +12,12 @@ Usage: docker node inspect [OPTIONS] self|NODE [NODE...] Display detailed information on one or more nodes Options: - -f, --format string Format the output using the given Go template - --help Print usage + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") --pretty Print the information in a human friendly format + --help Print usage ``` ## Description diff --git a/docs/reference/commandline/plugin_inspect.md b/docs/reference/commandline/plugin_inspect.md index 30caa13a36..2369dc1d1d 100644 --- a/docs/reference/commandline/plugin_inspect.md +++ b/docs/reference/commandline/plugin_inspect.md @@ -12,7 +12,10 @@ Usage: docker plugin inspect [OPTIONS] PLUGIN [PLUGIN...] Display detailed information on one or more plugins Options: - -f, --format string Format the output using the given Go template + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") --help Print usage ``` diff --git a/docs/reference/commandline/secret_inspect.md b/docs/reference/commandline/secret_inspect.md index 41c4724e4e..ba5cc91211 100644 --- a/docs/reference/commandline/secret_inspect.md +++ b/docs/reference/commandline/secret_inspect.md @@ -12,7 +12,11 @@ Usage: docker secret inspect [OPTIONS] SECRET [SECRET...] Display detailed information on one or more secrets Options: - -f, --format string Format the output using the given Go template + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") + --pretty Print the information in a human friendly format --help Print usage ``` diff --git a/docs/reference/commandline/service_inspect.md b/docs/reference/commandline/service_inspect.md index 1c204ee0f3..f284b7e94b 100644 --- a/docs/reference/commandline/service_inspect.md +++ b/docs/reference/commandline/service_inspect.md @@ -12,9 +12,12 @@ Usage: docker service inspect [OPTIONS] SERVICE [SERVICE...] Display detailed information on one or more services Options: - -f, --format string Format the output using the given Go template - --help Print usage + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") --pretty Print the information in a human friendly format + --help Print usage ``` ## Description diff --git a/docs/reference/commandline/volume_inspect.md b/docs/reference/commandline/volume_inspect.md index 5204310ac7..9c2e3b75b1 100644 --- a/docs/reference/commandline/volume_inspect.md +++ b/docs/reference/commandline/volume_inspect.md @@ -12,7 +12,10 @@ Usage: docker volume inspect [OPTIONS] VOLUME [VOLUME...] Display detailed information on one or more volumes Options: - -f, --format string Format the output using the given Go template + -f, --format string Format output using a custom template: + 'json': Print in JSON format + 'TEMPLATE': Print output using the given Go template. + Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "json") --help Print usage ```