summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-02-09 13:14:50 +0100
committerGitHub <noreply@github.com>2019-02-09 13:14:50 +0100
commit1fd9be022fc1484c9bdebfc41008d2344237073c (patch)
tree6ba0251ba7cbb9ec7c3339f793c2491897ff05be /cmd
parentafd4d5f4a4b05f421e6f336b4d74a0d808be57ed (diff)
parente071ac20f8531a50612c6fd240c90f008a4b2a19 (diff)
downloadpodman-1fd9be022fc1484c9bdebfc41008d2344237073c.tar.gz
podman-1fd9be022fc1484c9bdebfc41008d2344237073c.tar.bz2
podman-1fd9be022fc1484c9bdebfc41008d2344237073c.zip
Merge pull request #2297 from baude/issue2246
do not crash when displaying dangling images
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 6afc2d042..6f5a3e9f1 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -305,6 +305,7 @@ func getImagesJSONOutput(ctx context.Context, images []*adapter.ContainerImage)
// generateImagesOutput generates the images based on the format provided
func generateImagesOutput(ctx context.Context, images []*adapter.ContainerImage, opts imagesOptions) error {
+ templateMap := GenImageOutputMap()
if len(images) == 0 {
return nil
}
@@ -316,15 +317,17 @@ func generateImagesOutput(ctx context.Context, images []*adapter.ContainerImage,
out = formats.JSONStructArray{Output: imagesToGeneric([]imagesTemplateParams{}, imagesOutput)}
default:
imagesOutput := getImagesTemplateOutput(ctx, images, opts)
- out = formats.StdoutTemplateArray{Output: imagesToGeneric(imagesOutput, []imagesJSONParams{}), Template: opts.outputformat, Fields: imagesOutput[0].HeaderMap()}
+ out = formats.StdoutTemplateArray{Output: imagesToGeneric(imagesOutput, []imagesJSONParams{}), Template: opts.outputformat, Fields: templateMap}
}
return formats.Writer(out).Out()
}
-// HeaderMap produces a generic map of "headers" based on a line
-// of output
-func (i *imagesTemplateParams) HeaderMap() map[string]string {
- v := reflect.Indirect(reflect.ValueOf(i))
+// GenImageOutputMap generates the map used for outputting the images header
+// without requiring a populated image. This replaces the previous HeaderMap
+// call.
+func GenImageOutputMap() map[string]string {
+ io := imagesTemplateParams{}
+ v := reflect.Indirect(reflect.ValueOf(io))
values := make(map[string]string)
for i := 0; i < v.NumField(); i++ {