summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-11-27 15:31:22 +0100
committerGitHub <noreply@github.com>2019-11-27 15:31:22 +0100
commit2178875fa7975f00a4da15fef9809cd3fb74feba (patch)
tree10f039a78dec47c3b809c7a964b61fd6ee95af46 /libpod
parent27a09f8fab740749964d28b5ead1a43c6d77a7c8 (diff)
parent63e46cc85cb0a9523e9c48db7a88039e0baeac29 (diff)
downloadpodman-2178875fa7975f00a4da15fef9809cd3fb74feba.tar.gz
podman-2178875fa7975f00a4da15fef9809cd3fb74feba.tar.bz2
podman-2178875fa7975f00a4da15fef9809cd3fb74feba.zip
Merge pull request #4568 from openSUSE/history
Add support for image name history
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/image.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index fa75be44d..129ccd376 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -335,6 +335,21 @@ func (i *Image) Names() []string {
return i.image.Names
}
+// NamesHistory returns a string array of names previously associated with the
+// image, which may be a mixture of tags and digests
+func (i *Image) NamesHistory() []string {
+ if len(i.image.Names) > 0 && len(i.image.NamesHistory) > 0 &&
+ // We compare the latest (time-referenced) tags for equality and skip
+ // it in the history if they match to not display them twice. We have
+ // to compare like this, because `i.image.Names` (latest last) gets
+ // appended on retag, whereas `i.image.NamesHistory` gets prepended
+ // (latest first)
+ i.image.Names[len(i.image.Names)-1] == i.image.NamesHistory[0] {
+ return i.image.NamesHistory[1:]
+ }
+ return i.image.NamesHistory
+}
+
// RepoTags returns a string array of repotags associated with the image
func (i *Image) RepoTags() ([]string, error) {
var repoTags []string