summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2019-01-09 21:35:04 +0100
committerMiloslav Trmač <mitr@redhat.com>2019-01-14 04:07:23 +0100
commite060a19c8768c9dd65d1b8dcbd6da7ec9faa1163 (patch)
tree0f4750e81798bf4da23640b2b492384e1e190194 /libpod
parent1c19d19c6ef9627413e34b30a643bef9b2970acb (diff)
downloadpodman-e060a19c8768c9dd65d1b8dcbd6da7ec9faa1163.tar.gz
podman-e060a19c8768c9dd65d1b8dcbd6da7ec9faa1163.tar.bz2
podman-e060a19c8768c9dd65d1b8dcbd6da7ec9faa1163.zip
Use imageParts.normalizedReference in normalizeTag
This is another step to using reference values instead of strings here. CHANGES BEHAVIOR: docker.io/busybox is now normalized to docker.io/library/busybox. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/image.go10
-rw-r--r--libpod/image/image_test.go1
2 files changed, 9 insertions, 2 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 3d8cf2651..2457a1c22 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -459,13 +459,19 @@ func normalizeTag(tag string) (string, error) {
return "", 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)
+ ref, err = decomposedTag.referenceWithRegistry(DefaultLocalRegistry)
+ if err != nil {
+ return "", err
+ }
+ } else {
+ ref, err = decomposedTag.normalizedReference()
if err != nil {
return "", err
}
- tag = ref.String()
}
+ tag = ref.String()
// If the input does not have a tag, we need to add one (latest)
if !decomposedTag.isTagged {
tag = fmt.Sprintf("%s:%s", tag, decomposedTag.tag)
diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go
index 2a68fd273..a85cd5386 100644
--- a/libpod/image/image_test.go
+++ b/libpod/image/image_test.go
@@ -268,6 +268,7 @@ func TestNormalizeTag(t *testing.T) {
{"example.com/busybox:notlatest" + digestSuffix, "example.com/busybox:notlatest" + digestSuffix}, // Qualified name:tag@digest
{"busybox:latest", "localhost/busybox:latest"}, // Unqualified name-only
{"ns/busybox:latest", "localhost/ns/busybox:latest"}, // Unqualified with a dot-less namespace
+ {"docker.io/busybox:latest", "docker.io/library/busybox:latest"}, // docker.io without /library/
} {
res, err := normalizeTag(c.input)
if c.expected == "" {