mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +08:00
Remove imageParts.transport
It is only ever set to DefaulTransport, and all of the code is docker/reference-specific anyway, so there's no point in making this a variable. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
@ -10,7 +10,6 @@ import (
|
|||||||
// imageParts describes the parts of an image's name
|
// imageParts describes the parts of an image's name
|
||||||
type imageParts struct {
|
type imageParts struct {
|
||||||
unnormalizedRef reference.Named // WARNING: Did not go through docker.io[/library] normalization
|
unnormalizedRef reference.Named // WARNING: Did not go through docker.io[/library] normalization
|
||||||
transport string
|
|
||||||
registry string
|
registry string
|
||||||
name string
|
name string
|
||||||
tag string
|
tag string
|
||||||
@ -74,7 +73,6 @@ func decompose(input string) (imageParts, error) {
|
|||||||
name: imageName,
|
name: imageName,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
isTagged: isTagged,
|
isTagged: isTagged,
|
||||||
transport: DefaultTransport,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,49 +11,48 @@ func TestDecompose(t *testing.T) {
|
|||||||
|
|
||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
input string
|
input string
|
||||||
transport, registry, name, tag string
|
registry, name, tag string
|
||||||
isTagged, hasRegistry bool
|
isTagged, hasRegistry bool
|
||||||
assembled string
|
assembled 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.io", "library/busybox", "latest", false, true,
|
||||||
"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", "example.com", "ns/busybox", "latest", false, true,
|
||||||
"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", "", "busybox", "latest", false, false,
|
||||||
"busybox:latest",
|
"busybox:latest",
|
||||||
},
|
},
|
||||||
{ // Unqualified namespaced input
|
{ // Unqualified namespaced input
|
||||||
"ns/busybox", "docker://", "", "ns/busybox", "latest", false, false,
|
"ns/busybox", "", "ns/busybox", "latest", false, false,
|
||||||
"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", "example.com", "ns/busybox", "notlatest", true, true,
|
||||||
"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, "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",
|
"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, "example.com", "ns/busybox", "notlatest", true, true,
|
||||||
// FIXME: This drops the digest
|
// FIXME: This drops the digest
|
||||||
"example.com/ns/busybox:notlatest",
|
"example.com/ns/busybox:notlatest",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
parts, err := decompose(c.input)
|
parts, err := decompose(c.input)
|
||||||
if c.transport == "" {
|
if c.assembled == "" {
|
||||||
assert.Error(t, err, c.input)
|
assert.Error(t, err, c.input)
|
||||||
} else {
|
} else {
|
||||||
assert.NoError(t, err, c.input)
|
assert.NoError(t, err, c.input)
|
||||||
assert.Equal(t, c.transport, parts.transport, c.input)
|
|
||||||
assert.Equal(t, c.registry, parts.registry, c.input)
|
assert.Equal(t, c.registry, parts.registry, c.input)
|
||||||
assert.Equal(t, c.name, parts.name, c.input)
|
assert.Equal(t, c.name, parts.name, c.input)
|
||||||
assert.Equal(t, c.tag, parts.tag, c.input)
|
assert.Equal(t, c.tag, parts.tag, c.input)
|
||||||
|
@ -290,7 +290,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG
|
|||||||
} else {
|
} else {
|
||||||
imageName = decomposedImage.assemble()
|
imageName = decomposedImage.assemble()
|
||||||
}
|
}
|
||||||
srcRef, err := alltransports.ParseImageName(fmt.Sprintf("%s%s", decomposedImage.transport, imageName))
|
srcRef, err := alltransports.ParseImageName(fmt.Sprintf("%s%s", DefaultTransport, imageName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
|
return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG
|
|||||||
if hasShaInInputName(inputName) {
|
if hasShaInInputName(inputName) {
|
||||||
imageName = fmt.Sprintf("%s/%s", registry, inputName)
|
imageName = fmt.Sprintf("%s/%s", registry, inputName)
|
||||||
}
|
}
|
||||||
srcRef, err := alltransports.ParseImageName(fmt.Sprintf("%s%s", decomposedImage.transport, imageName))
|
srcRef, err := alltransports.ParseImageName(fmt.Sprintf("%s%s", DefaultTransport, imageName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
|
return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user