image ls: allow custom format in cli config

Setting a custom format in the cli cofig should still be supported,
and not produce an error when specifying "--tree". Specifyihg both
"--tree" and "--format" still produces an error, but we could consider
allowing "json" format in a future update.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-11-20 15:43:09 +00:00
parent 8108357bcb
commit d84396d4eb
2 changed files with 10 additions and 10 deletions

View File

@ -114,6 +114,16 @@ func runImages(ctx context.Context, dockerCLI command.Cli, options imagesOptions
}
}
format := options.format
if len(format) == 0 {
if len(dockerCLI.ConfigFile().ImagesFormat) > 0 && !options.quiet && !options.tree {
format = dockerCLI.ConfigFile().ImagesFormat
useTree = false
} else {
format = formatter.TableFormatKey
}
}
if useTree {
return runTree(ctx, dockerCLI, treeOptions{
images: images,
@ -123,15 +133,6 @@ func runImages(ctx context.Context, dockerCLI command.Cli, options imagesOptions
})
}
format := options.format
if len(format) == 0 {
if len(dockerCLI.ConfigFile().ImagesFormat) > 0 && !options.quiet {
format = dockerCLI.ConfigFile().ImagesFormat
} else {
format = formatter.TableFormatKey
}
}
imageCtx := formatter.ImageContext{
Context: formatter.Context{
Output: dockerCLI.Out(),

View File

@ -1 +0,0 @@
IMAGE ID DISK USAGE CONTENT SIZE EXTRA