mirror of
https://github.com/containers/podman.git
synced 2025-06-19 00:06:43 +08:00
Inline imageParts.assembleWithTransport into callers
imageParts.transport is a constant, and the design of imageParts is not transport-independent in any sense; we will want to eliminate the transport member entirely. As a first step, drop assembleWithTransport and inline an exact equivalent into all callers. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
@ -87,8 +87,3 @@ func (ip *imageParts) assemble() string {
|
|||||||
}
|
}
|
||||||
return spec
|
return spec
|
||||||
}
|
}
|
||||||
|
|
||||||
// assemble concatenates an image's parts with transport into a string
|
|
||||||
func (ip *imageParts) assembleWithTransport() string {
|
|
||||||
return fmt.Sprintf("%s%s", ip.transport, ip.assemble())
|
|
||||||
}
|
|
||||||
|
@ -14,39 +14,38 @@ func TestDecompose(t *testing.T) {
|
|||||||
transport, registry, name, tag string
|
transport, registry, name, tag string
|
||||||
isTagged, hasRegistry bool
|
isTagged, hasRegistry bool
|
||||||
assembled string
|
assembled string
|
||||||
assembledWithTransport string
|
|
||||||
}{
|
}{
|
||||||
{"#", "", "", "", "", false, false, "", ""}, // Entirely invalid input
|
{"#", "", "", "", "", false, false, ""}, // Entirely invalid input
|
||||||
{ // Fully qualified docker.io, name-only input
|
{ // Fully qualified docker.io, name-only input
|
||||||
"docker.io/library/busybox", "docker://", "docker.io", "library/busybox", "latest", false, true,
|
"docker.io/library/busybox", "docker://", "docker.io", "library/busybox", "latest", false, true,
|
||||||
"docker.io/library/busybox:latest", "docker://docker.io/library/busybox:latest",
|
"docker.io/library/busybox:latest",
|
||||||
},
|
},
|
||||||
{ // Fully qualified example.com, name-only input
|
{ // Fully qualified example.com, name-only input
|
||||||
"example.com/ns/busybox", "docker://", "example.com", "ns/busybox", "latest", false, true,
|
"example.com/ns/busybox", "docker://", "example.com", "ns/busybox", "latest", false, true,
|
||||||
"example.com/ns/busybox:latest", "docker://example.com/ns/busybox:latest",
|
"example.com/ns/busybox:latest",
|
||||||
},
|
},
|
||||||
{ // Unqualified single-name input
|
{ // Unqualified single-name input
|
||||||
"busybox", "docker://", "", "busybox", "latest", false, false,
|
"busybox", "docker://", "", "busybox", "latest", false, false,
|
||||||
"busybox:latest", "docker://busybox:latest",
|
"busybox:latest",
|
||||||
},
|
},
|
||||||
{ // Unqualified namespaced input
|
{ // Unqualified namespaced input
|
||||||
"ns/busybox", "docker://", "", "ns/busybox", "latest", false, false,
|
"ns/busybox", "docker://", "", "ns/busybox", "latest", false, false,
|
||||||
"ns/busybox:latest", "docker://ns/busybox:latest",
|
"ns/busybox:latest",
|
||||||
},
|
},
|
||||||
{ // name:tag
|
{ // name:tag
|
||||||
"example.com/ns/busybox:notlatest", "docker://", "example.com", "ns/busybox", "notlatest", true, true,
|
"example.com/ns/busybox:notlatest", "docker://", "example.com", "ns/busybox", "notlatest", true, true,
|
||||||
"example.com/ns/busybox:notlatest", "docker://example.com/ns/busybox:notlatest",
|
"example.com/ns/busybox:notlatest",
|
||||||
},
|
},
|
||||||
{ // name@digest
|
{ // name@digest
|
||||||
// FIXME? .tag == "none"
|
// FIXME? .tag == "none"
|
||||||
"example.com/ns/busybox" + digestSuffix, "docker://", "example.com", "ns/busybox", "none", false, true,
|
"example.com/ns/busybox" + digestSuffix, "docker://", "example.com", "ns/busybox", "none", false, true,
|
||||||
// FIXME: this drops the digest and replaces it with an incorrect tag.
|
// FIXME: this drops the digest and replaces it with an incorrect tag.
|
||||||
"example.com/ns/busybox:none", "docker://example.com/ns/busybox:none",
|
"example.com/ns/busybox:none",
|
||||||
},
|
},
|
||||||
{ // name:tag@digest
|
{ // name:tag@digest
|
||||||
"example.com/ns/busybox:notlatest" + digestSuffix, "docker://", "example.com", "ns/busybox", "notlatest", true, true,
|
"example.com/ns/busybox:notlatest" + digestSuffix, "docker://", "example.com", "ns/busybox", "notlatest", true, true,
|
||||||
// FIXME: This drops the digest
|
// FIXME: This drops the digest
|
||||||
"example.com/ns/busybox:notlatest", "docker://example.com/ns/busybox:notlatest",
|
"example.com/ns/busybox:notlatest",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
parts, err := decompose(c.input)
|
parts, err := decompose(c.input)
|
||||||
@ -61,7 +60,6 @@ func TestDecompose(t *testing.T) {
|
|||||||
assert.Equal(t, c.isTagged, parts.isTagged, c.input)
|
assert.Equal(t, c.isTagged, parts.isTagged, c.input)
|
||||||
assert.Equal(t, c.hasRegistry, parts.hasRegistry, c.input)
|
assert.Equal(t, c.hasRegistry, parts.hasRegistry, c.input)
|
||||||
assert.Equal(t, c.assembled, parts.assemble(), c.input)
|
assert.Equal(t, c.assembled, parts.assemble(), c.input)
|
||||||
assert.Equal(t, c.assembledWithTransport, parts.assembleWithTransport(), c.input)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG
|
|||||||
if hasShaInInputName(inputName) {
|
if hasShaInInputName(inputName) {
|
||||||
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, inputName)
|
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, inputName)
|
||||||
} else {
|
} else {
|
||||||
imageName = decomposedImage.assembleWithTransport()
|
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, decomposedImage.assemble())
|
||||||
}
|
}
|
||||||
srcRef, err := alltransports.ParseImageName(imageName)
|
srcRef, err := alltransports.ParseImageName(imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -318,7 +318,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG
|
|||||||
var refPairs []pullRefPair
|
var refPairs []pullRefPair
|
||||||
for _, registry := range searchRegistries {
|
for _, registry := range searchRegistries {
|
||||||
decomposedImage.registry = registry
|
decomposedImage.registry = registry
|
||||||
imageName := decomposedImage.assembleWithTransport()
|
imageName := fmt.Sprintf("%s%s", decomposedImage.transport, decomposedImage.assemble())
|
||||||
if hasShaInInputName(inputName) {
|
if hasShaInInputName(inputName) {
|
||||||
imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, inputName)
|
imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, inputName)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user