From d2090430a6256fd98dc9ca6eaa8416e59d87ecaf Mon Sep 17 00:00:00 2001 From: Anda Xu Date: Mon, 21 May 2018 09:48:24 -0700 Subject: [PATCH] fix error message from docker inspect Signed-off-by: Anda Xu --- cli/command/system/inspect.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cli/command/system/inspect.go b/cli/command/system/inspect.go index ef06f09974..437cd702fb 100644 --- a/cli/command/system/inspect.go +++ b/cli/command/system/inspect.go @@ -170,10 +170,6 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, return info.Swarm.ControlAvailable } - isErrNotSupported := func(err error) bool { - return strings.Contains(err.Error(), "not supported") - } - return func(ref string) (interface{}, []byte, error) { const ( swarmSupportUnknown = iota @@ -201,7 +197,7 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, } v, raw, err := inspectData.objectInspector(ref) if err != nil { - if typeConstraint == "" && (apiclient.IsErrNotFound(err) || isErrNotSupported(err)) { + if typeConstraint == "" && isErrSkippable(err) { continue } return v, raw, err @@ -214,3 +210,9 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, return nil, nil, errors.Errorf("Error: No such object: %s", ref) } } + +func isErrSkippable(err error) bool { + return apiclient.IsErrNotFound(err) || + strings.Contains(err.Error(), "not supported") || + strings.Contains(err.Error(), "invalid reference format") +}