mirror of
https://github.com/containers/podman.git
synced 2025-06-04 04:56:32 +08:00
Use imageParts.referenceWithRegistry in getPullRefPair
CHANGES BEHAVIOR. This bypasses .assemble, and preserves the original lack of tag / original digest instead of adding :latest/:none (still subject to ParseStoreReference normalization). Using the original digest seems clearly correct; dropping the :latest suffix from .image strings only affects user-visible input; later uses of the return value of pullImageFrom... use ParseStoreReference, which calls reference.TagNameOnly, so the image name should be processed the same way whether it contains a tag or not. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
@ -76,9 +76,11 @@ func (ir *Runtime) getPullRefPair(srcRef types.ImageReference, destName string)
|
|||||||
decomposedDest, err := decompose(destName)
|
decomposedDest, err := decompose(destName)
|
||||||
if err == nil && !decomposedDest.hasRegistry {
|
if err == nil && !decomposedDest.hasRegistry {
|
||||||
// If the image doesn't have a registry, set it as the default repo
|
// If the image doesn't have a registry, set it as the default repo
|
||||||
decomposedDest.registry = DefaultLocalRegistry
|
ref, err := decomposedDest.referenceWithRegistry(DefaultLocalRegistry)
|
||||||
decomposedDest.hasRegistry = true
|
if err != nil {
|
||||||
destName = decomposedDest.assemble()
|
return pullRefPair{}, err
|
||||||
|
}
|
||||||
|
destName = ref.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
reference := destName
|
reference := destName
|
||||||
|
@ -76,9 +76,7 @@ func TestGetPullRefPair(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{ // name, no registry, no tag:
|
{ // name, no registry, no tag:
|
||||||
"dir:/dev/this-does-not-exist", "from-directory",
|
"dir:/dev/this-does-not-exist", "from-directory",
|
||||||
// FIXME(?) Adding a registry also adds a :latest tag. OTOH that actually matches the used destination.
|
"localhost/from-directory", "localhost/from-directory:latest",
|
||||||
// Either way it is surprising that the localhost/ addition changes this. (mitr hoping to remove the "image" member).
|
|
||||||
"localhost/from-directory:latest", "localhost/from-directory:latest",
|
|
||||||
},
|
},
|
||||||
{ // registry/name:tag :
|
{ // registry/name:tag :
|
||||||
"dir:/dev/this-does-not-exist", "example.com/from-directory:notlatest",
|
"dir:/dev/this-does-not-exist", "example.com/from-directory:notlatest",
|
||||||
@ -90,8 +88,7 @@ func TestGetPullRefPair(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{ // name@digest, no registry:
|
{ // name@digest, no registry:
|
||||||
"dir:/dev/this-does-not-exist", "from-directory" + digestSuffix,
|
"dir:/dev/this-does-not-exist", "from-directory" + digestSuffix,
|
||||||
// FIXME?! Why is this dropping the digest, and adding :none?!
|
"localhost/from-directory" + digestSuffix, "localhost/from-directory" + digestSuffix,
|
||||||
"localhost/from-directory:none", "localhost/from-directory:none",
|
|
||||||
},
|
},
|
||||||
{ // registry/name@digest:
|
{ // registry/name@digest:
|
||||||
"dir:/dev/this-does-not-exist", "example.com/from-directory" + digestSuffix,
|
"dir:/dev/this-does-not-exist", "example.com/from-directory" + digestSuffix,
|
||||||
@ -211,14 +208,13 @@ func TestPullGoalFromImageReference(t *testing.T) {
|
|||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{ // Relative path, single element.
|
{ // Relative path, single element.
|
||||||
// FIXME? Note the :latest difference in .image.
|
|
||||||
"dir:this-does-not-exist",
|
"dir:this-does-not-exist",
|
||||||
[]expected{{"localhost/this-does-not-exist:latest", "localhost/this-does-not-exist:latest"}},
|
[]expected{{"localhost/this-does-not-exist", "localhost/this-does-not-exist:latest"}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{ // Relative path, multiple elements.
|
{ // Relative path, multiple elements.
|
||||||
"dir:testdata/this-does-not-exist",
|
"dir:testdata/this-does-not-exist",
|
||||||
[]expected{{"localhost/testdata/this-does-not-exist:latest", "localhost/testdata/this-does-not-exist:latest"}},
|
[]expected{{"localhost/testdata/this-does-not-exist", "localhost/testdata/this-does-not-exist:latest"}},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user