From 6c7da0ca57b54f8e30b927c26765fb884e6666ce Mon Sep 17 00:00:00 2001 From: Santhosh Manohar Date: Thu, 9 Mar 2017 11:42:10 -0800 Subject: [PATCH] Enhance network inspect to show all tasks, local & non-local, in swarm mode Signed-off-by: Santhosh Manohar --- command/network/inspect.go | 8 +++++--- command/stack/deploy_composefile.go | 2 +- command/system/inspect.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/command/network/inspect.go b/command/network/inspect.go index 1a86855f71..e58d66b77a 100644 --- a/command/network/inspect.go +++ b/command/network/inspect.go @@ -10,8 +10,9 @@ import ( ) type inspectOptions struct { - format string - names []string + format string + names []string + verbose bool } func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { @@ -28,6 +29,7 @@ func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command { } cmd.Flags().StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") + cmd.Flags().BoolVarP(&opts.verbose, "verbose", "v", false, "Verbose output for diagnostics") return cmd } @@ -38,7 +40,7 @@ func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error { ctx := context.Background() getNetFunc := func(name string) (interface{}, []byte, error) { - return client.NetworkInspectWithRaw(ctx, name) + return client.NetworkInspectWithRaw(ctx, name, opts.verbose) } return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc) diff --git a/command/stack/deploy_composefile.go b/command/stack/deploy_composefile.go index 72f9b8aac9..3e62494325 100644 --- a/command/stack/deploy_composefile.go +++ b/command/stack/deploy_composefile.go @@ -140,7 +140,7 @@ func validateExternalNetworks( client := dockerCli.Client() for _, networkName := range externalNetworks { - network, err := client.NetworkInspect(ctx, networkName) + network, err := client.NetworkInspect(ctx, networkName, false) if err != nil { if dockerclient.IsErrNetworkNotFound(err) { return fmt.Errorf("network %q is declared as external, but could not be found. You need to create the network before the stack is deployed (with overlay driver)", networkName) diff --git a/command/system/inspect.go b/command/system/inspect.go index c86e858a29..6bb9cbe041 100644 --- a/command/system/inspect.go +++ b/command/system/inspect.go @@ -67,7 +67,7 @@ func inspectImages(ctx context.Context, dockerCli *command.DockerCli) inspect.Ge func inspectNetwork(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc { return func(ref string) (interface{}, []byte, error) { - return dockerCli.Client().NetworkInspectWithRaw(ctx, ref) + return dockerCli.Client().NetworkInspectWithRaw(ctx, ref, false) } }