diff options
author | Miloslav Trmač <mitr@redhat.com> | 2019-01-09 21:42:37 +0100 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2019-01-14 04:07:23 +0100 |
commit | f92c3ce35033a558a9c86c824a829368a472f873 (patch) | |
tree | df4a527285d53d505790993ea6e6db6bb23fbf9b /libpod/image/image.go | |
parent | b9c0f2c987688a8e7ee2c8f4e4fbf6b1a8fee024 (diff) | |
download | podman-f92c3ce35033a558a9c86c824a829368a472f873.tar.gz podman-f92c3ce35033a558a9c86c824a829368a472f873.tar.bz2 podman-f92c3ce35033a558a9c86c824a829368a472f873.zip |
Return a reference.Named from normalizedTag
Instead of returning a string, return a native value and convert it
into the string in the caller, to make it that small bit more
common to use reference types.
Should not change behavior.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r-- | libpod/image/image.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go index 0b743e144..7442f1945 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -452,42 +452,42 @@ func getImageDigest(ctx context.Context, src types.ImageReference, sc *types.Sys return "@" + digest.Hex(), nil } -// normalizeTag returns the canonical version of tag for use in Image.Names() -func normalizeTag(tag string) (string, error) { +// normalizedTag returns the canonical version of tag for use in Image.Names() +func normalizedTag(tag string) (reference.Named, error) { decomposedTag, err := decompose(tag) if err != nil { - return "", err + return nil, err } // If the input doesn't specify a registry, set the registry to localhost var ref reference.Named if !decomposedTag.hasRegistry { ref, err = decomposedTag.referenceWithRegistry(DefaultLocalRegistry) if err != nil { - return "", err + return nil, err } } else { ref, err = decomposedTag.normalizedReference() if err != nil { - return "", err + return nil, err } } // If the input does not have a tag, we need to add one (latest) ref = reference.TagNameOnly(ref) - return ref.String(), nil + return ref, nil } // TagImage adds a tag to the given image func (i *Image) TagImage(tag string) error { i.reloadImage() - tag, err := normalizeTag(tag) + ref, err := normalizedTag(tag) if err != nil { return err } tags := i.Names() - if util.StringInSlice(tag, tags) { + if util.StringInSlice(ref.String(), tags) { return nil } - tags = append(tags, tag) + tags = append(tags, ref.String()) if err := i.imageruntime.store.SetNames(i.ID(), tags); err != nil { return err } |