diff options
author | baude <bbaude@redhat.com> | 2019-03-10 15:26:08 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-03-15 13:41:01 -0500 |
commit | 5e86acd591700b1aed1dd4bc3697f294ac11d0f2 (patch) | |
tree | 4baf45edd5870d0794f429d43c1662a7dbb9a613 /cmd/podman/search.go | |
parent | 6e4c32967ec02cdc33b801df8b5730dffce9b8a3 (diff) | |
download | podman-5e86acd591700b1aed1dd4bc3697f294ac11d0f2.tar.gz podman-5e86acd591700b1aed1dd4bc3697f294ac11d0f2.tar.bz2 podman-5e86acd591700b1aed1dd4bc3697f294ac11d0f2.zip |
display logs for multiple containers at the same time
add the ability for users to specify more than one container at a time
while using podman logs. If more than one container is being displayed,
podman will also prepend a shortened container id of the container on
the log line.
also, enabled the podman-remote logs command during the refactoring of
the above ability.
fixes issue #2219
Signed-off-by: baude <bbaude@redhat.com>
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 +} |