summaryrefslogtreecommitdiff
path: root/libpod/image/parts.go
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2019-01-09 21:33:01 +0100
committerMiloslav Trmač <mitr@redhat.com>2019-01-14 04:07:23 +0100
commit1c19d19c6ef9627413e34b30a643bef9b2970acb (patch)
treec2b7c6400a9a12b7e0469370a050cfa4d82b8053 /libpod/image/parts.go
parente58aa74766c14844700330e11e8f0b48843884be (diff)
downloadpodman-1c19d19c6ef9627413e34b30a643bef9b2970acb.tar.gz
podman-1c19d19c6ef9627413e34b30a643bef9b2970acb.tar.bz2
podman-1c19d19c6ef9627413e34b30a643bef9b2970acb.zip
Add imageParts.normalizedReference()
This will be used in normalizeTag to work with references instead of strings. Not used anywhere yet, should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod/image/parts.go')
-rw-r--r--libpod/image/parts.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/image/parts.go b/libpod/image/parts.go
index 566a3842c..a4eb57519 100644
--- a/libpod/image/parts.go
+++ b/libpod/image/parts.go
@@ -92,3 +92,17 @@ func (ip *imageParts) referenceWithRegistry(registry string) (reference.Named, e
}
return ref, nil
}
+
+// normalizedReference returns a (normalized) reference for ip (with ip.hasRegistry)
+func (ip *imageParts) normalizedReference() (reference.Named, error) {
+ if !ip.hasRegistry {
+ return nil, errors.Errorf("internal error: normalizedReference called on imageParts without a registry (%#v)", *ip)
+ }
+ // We need to round-trip via a string to get the right normalization of docker.io/library
+ s := ip.unnormalizedRef.String()
+ ref, err := reference.ParseNormalizedNamed(s)
+ if err != nil { // Should never happen
+ return nil, errors.Wrapf(err, "error normalizing qualified reference %#v", s)
+ }
+ return ref, nil
+}