summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-08-05 15:10:12 -0700
committerJhon Honce <jhonce@redhat.com>2020-08-10 08:03:58 -0700
commitc60b695e64227d18d825e8ab11c2be309e4b789a (patch)
tree0a66b2571b6b76f0de76d55d513c62bbec42e737 /cmd
parentda00482ef29e0a04a690f1538391e38b0b951dd0 (diff)
downloadpodman-c60b695e64227d18d825e8ab11c2be309e4b789a.tar.gz
podman-c60b695e64227d18d825e8ab11c2be309e4b789a.tar.bz2
podman-c60b695e64227d18d825e8ab11c2be309e4b789a.zip
Default .Repository and .Tag values to <none>
Refactor the processing of Repository and Tag fields to default to <none> when printing via --format flag. Previously, the default format would print <none> but --format {{.Tag}} would not in some cases. Fixes #7123 Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/list.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go
index ee0f64d99..043871a8c 100644
--- a/cmd/podman/images/list.go
+++ b/cmd/podman/images/list.go
@@ -195,6 +195,7 @@ func sortImages(imageS []*entities.ImageSummary) ([]imageReporter, error) {
} else {
h.ImageSummary = *e
h.Repository = "<none>"
+ h.Tag = "<none>"
imgs = append(imgs, h)
}
listFlag.readOnly = e.IsReadOnly()
@@ -205,27 +206,34 @@ func sortImages(imageS []*entities.ImageSummary) ([]imageReporter, error) {
}
func tokenRepoTag(ref string) (string, string, error) {
-
if ref == "<none>:<none>" {
return "<none>", "<none>", nil
}
repo, err := reference.Parse(ref)
if err != nil {
- return "", "", err
+ return "<none>", "<none>", err
}
named, ok := repo.(reference.Named)
if !ok {
- return ref, "", nil
+ return ref, "<none>", nil
+ }
+ name := named.Name()
+ if name == "" {
+ name = "<none>"
}
tagged, ok := repo.(reference.Tagged)
if !ok {
- return named.Name(), "", nil
+ return name, "<none>", nil
+ }
+ tag := tagged.Tag()
+ if tag == "" {
+ tag = "<none>"
}
- return named.Name(), tagged.Tag(), nil
+ return name, tag, nil
}