mirror of
https://github.com/containers/podman.git
synced 2025-06-19 00:06:43 +08:00
Use reference.TagNameOnly instead of manually adding imageParts.tag in normalizeTag
Again, rely on the official API, instead of the suprising "suspiciousTagValueForSearch" value (set to :latest on untagged images, and :none on digested ones!) CHANGES BEHAVIOR, but the previous output of normalization of digested values was not even syntatically valid, so this can't really be worse. Still, maybe we should refuse to tag with digested references in the first place. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
@ -471,12 +471,9 @@ func normalizeTag(tag string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag = ref.String()
|
|
||||||
// If the input does not have a tag, we need to add one (latest)
|
// If the input does not have a tag, we need to add one (latest)
|
||||||
if !decomposedTag.isTagged {
|
ref = reference.TagNameOnly(ref)
|
||||||
tag = fmt.Sprintf("%s:%s", tag, decomposedTag.tag)
|
return ref.String(), nil
|
||||||
}
|
|
||||||
return tag, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TagImage adds a tag to the given image
|
// TagImage adds a tag to the given image
|
||||||
|
@ -264,7 +264,7 @@ func TestNormalizeTag(t *testing.T) {
|
|||||||
{"#", ""}, // Clearly invalid
|
{"#", ""}, // Clearly invalid
|
||||||
{"example.com/busybox", "example.com/busybox:latest"}, // Qualified name-only
|
{"example.com/busybox", "example.com/busybox:latest"}, // Qualified name-only
|
||||||
{"example.com/busybox:notlatest", "example.com/busybox:notlatest"}, // Qualified name:tag
|
{"example.com/busybox:notlatest", "example.com/busybox:notlatest"}, // Qualified name:tag
|
||||||
{"example.com/busybox" + digestSuffix, "example.com/busybox" + digestSuffix + ":none"}, // Qualified name@digest; FIXME: The result is not even syntactically valid!
|
{"example.com/busybox" + digestSuffix, "example.com/busybox" + digestSuffix}, // Qualified name@digest; FIXME? Should we allow tagging with a digest at all?
|
||||||
{"example.com/busybox:notlatest" + digestSuffix, "example.com/busybox:notlatest" + digestSuffix}, // Qualified name:tag@digest
|
{"example.com/busybox:notlatest" + digestSuffix, "example.com/busybox:notlatest" + digestSuffix}, // Qualified name:tag@digest
|
||||||
{"busybox:latest", "localhost/busybox:latest"}, // Unqualified name-only
|
{"busybox:latest", "localhost/busybox:latest"}, // Unqualified name-only
|
||||||
{"ns/busybox:latest", "localhost/ns/busybox:latest"}, // Unqualified with a dot-less namespace
|
{"ns/busybox:latest", "localhost/ns/busybox:latest"}, // Unqualified with a dot-less namespace
|
||||||
|
Reference in New Issue
Block a user