diff options
author | Alexandre Fourcat <afourcat@gmail.com> | 2021-01-10 21:27:04 +0900 |
---|---|---|
committer | Alexandre Fourcat <afourcat@gmail.com> | 2021-01-11 19:14:18 +0900 |
commit | 95462e802a53e7fee38847b0b66200a8edc8a4ba (patch) | |
tree | 74a0d41147466329c9cca0a2add1b09807fe9abf /cmd/podman/images/search.go | |
parent | e1302a302314cb6b7a5558c0b8c36ce722d5cc20 (diff) | |
download | podman-95462e802a53e7fee38847b0b66200a8edc8a4ba.tar.gz podman-95462e802a53e7fee38847b0b66200a8edc8a4ba.tar.bz2 podman-95462e802a53e7fee38847b0b66200a8edc8a4ba.zip |
Better test and idomatic code.
Adding another check in the `podman search --list-tags --format json` test case.
Replacing an anonymous struct by \`listEntryTag\` struct.
Signed-off-by: Alexandre Fourcat <afourcat@gmail.com>
Diffstat (limited to 'cmd/podman/images/search.go')
-rw-r--r-- | cmd/podman/images/search.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go index e4d325361..c8ea4b04a 100644 --- a/cmd/podman/images/search.go +++ b/cmd/podman/images/search.go @@ -26,6 +26,12 @@ type searchOptionsWrapper struct { Format string // For go templating } +// listEntryTag is a utility structure used for json serialization. +type listEntryTag struct { + Name string + Tags []string +} + var ( searchOptions = searchOptionsWrapper{} searchDescription = `Search registries for a given image. Can search all the default registries or a specific registry. @@ -189,11 +195,8 @@ func printJson(v interface{}) error { return nil } -func buildListTagsJson(searchReport []entities.ImageSearchReport) interface{} { - entries := []struct { - Name string - Tags []string - }{} +func buildListTagsJson(searchReport []entities.ImageSearchReport) []listEntryTag { + entries := []listEntryTag{} ReportLoop: for _, report := range searchReport { @@ -203,10 +206,7 @@ ReportLoop: continue ReportLoop } } - newElem := struct { - Name string - Tags []string - }{ + newElem := listEntryTag{ report.Name, []string{report.Tag}, } |