diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-16 04:21:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-16 04:21:32 -0700 |
commit | 97fb49571828b9d206ff284ed18448f96ae877e9 (patch) | |
tree | b1b5c7ecb963a4bc012bf0f65c287862644938b3 /cmd/podman/search.go | |
parent | 3384bd87c85950c245524682efa2a0f124097122 (diff) | |
parent | a0c35c394bb95d15aeed8fcc467cb110f67fa6db (diff) | |
download | podman-97fb49571828b9d206ff284ed18448f96ae877e9.tar.gz podman-97fb49571828b9d206ff284ed18448f96ae877e9.tar.bz2 podman-97fb49571828b9d206ff284ed18448f96ae877e9.zip |
Merge pull request #2620 from baude/multilogs
display logs for multiple containers at the same time
Diffstat (limited to 'cmd/podman/search.go')
-rw-r--r-- | cmd/podman/search.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/podman/search.go b/cmd/podman/search.go index 5997e144a..a10b9d419 100644 --- a/cmd/podman/search.go +++ b/cmd/podman/search.go @@ -1,6 +1,7 @@ package main import ( + "reflect" "strings" "github.com/containers/buildah/pkg/formats" @@ -79,7 +80,10 @@ func searchCmd(c *cliconfig.SearchValues) error { return err } format := genSearchFormat(c.Format) - out := formats.StdoutTemplateArray{Output: searchToGeneric(results), Template: format, Fields: results[0].HeaderMap()} + if len(results) == 0 { + return nil + } + out := formats.StdoutTemplateArray{Output: searchToGeneric(results), Template: format, Fields: genSearchOutputMap()} formats.Writer(out).Out() return nil } @@ -99,3 +103,16 @@ func searchToGeneric(params []image.SearchResult) (genericParams []interface{}) } return genericParams } + +func genSearchOutputMap() map[string]string { + io := image.SearchResult{} + v := reflect.Indirect(reflect.ValueOf(io)) + values := make(map[string]string) + + for i := 0; i < v.NumField(); i++ { + key := v.Type().Field(i).Name + value := key + values[key] = strings.ToUpper(splitCamelCase(value)) + } + return values +} |