mirror of https://github.com/docker/cli.git
Fix issue of `WARNING: --size ignored for volume` for `docker inspect`
When `docker inspect` is invoked, it is possible to pass a flag of `-s` for container types to display size information. If `-s` is used for non-container types then a warning `WARNING: --size ignored for volume` will show up. However, currently `WARNING: --size ignored for volume` will show up even when `-s` is not passed to `docker inspect` for non-container types. This fix fixes this issue by checking if `-s` has been passed or not (`getSize`). Also, since image inspect does not support `-s`, `IsSizeSupported` has been changed to false for images. This fix is tested manually. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
d23d33781a
commit
9aba07679f
|
@ -102,7 +102,7 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool,
|
||||||
ObjectInspector func(string) (interface{}, []byte, error)
|
ObjectInspector func(string) (interface{}, []byte, error)
|
||||||
}{
|
}{
|
||||||
{"container", true, inspectContainers(ctx, dockerCli, getSize)},
|
{"container", true, inspectContainers(ctx, dockerCli, getSize)},
|
||||||
{"image", true, inspectImages(ctx, dockerCli)},
|
{"image", false, inspectImages(ctx, dockerCli)},
|
||||||
{"network", false, inspectNetwork(ctx, dockerCli)},
|
{"network", false, inspectNetwork(ctx, dockerCli)},
|
||||||
{"volume", false, inspectVolume(ctx, dockerCli)},
|
{"volume", false, inspectVolume(ctx, dockerCli)},
|
||||||
{"service", false, inspectService(ctx, dockerCli)},
|
{"service", false, inspectService(ctx, dockerCli)},
|
||||||
|
@ -126,7 +126,7 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool,
|
||||||
}
|
}
|
||||||
return v, raw, err
|
return v, raw, err
|
||||||
}
|
}
|
||||||
if !inspectData.IsSizeSupported {
|
if getSize && !inspectData.IsSizeSupported {
|
||||||
fmt.Fprintf(dockerCli.Err(), "WARNING: --size ignored for %s\n", inspectData.ObjectType)
|
fmt.Fprintf(dockerCli.Err(), "WARNING: --size ignored for %s\n", inspectData.ObjectType)
|
||||||
}
|
}
|
||||||
return v, raw, err
|
return v, raw, err
|
||||||
|
|
Loading…
Reference in New Issue