aboutsummaryrefslogtreecommitdiff
path: root/libpod/image/pull.go
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-19 00:58:26 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-23 12:44:38 +0000
commit38842bd4075f35073ba64ee52c329a408d54b088 (patch)
tree6b520fe3969332e0d05c62dbb7cbbd14b80bc6d5 /libpod/image/pull.go
parent3b964a4d9a6023375df736cd09f7375805bd3608 (diff)
downloadpodman-38842bd4075f35073ba64ee52c329a408d54b088.tar.gz
podman-38842bd4075f35073ba64ee52c329a408d54b088.tar.bz2
podman-38842bd4075f35073ba64ee52c329a408d54b088.zip
Make refNamesFromPossiblyUnqualifiedName independent from Image
... which finally makes it very easy to add comprehensive tests; so do that. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
Diffstat (limited to 'libpod/image/pull.go')
-rw-r--r--libpod/image/pull.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 529378019..cc60c8894 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -272,31 +272,31 @@ func hasShaInInputName(inputName string) bool {
// refNamesFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
// image names to try pulling in combination with the registries.conf file as well
-func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
+func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, error) {
var (
pullNames []*pullRefName
imageName string
)
- decomposedImage, err := decompose(i.InputName)
+ decomposedImage, err := decompose(inputName)
if err != nil {
return nil, err
}
if decomposedImage.hasRegistry {
- if hasShaInInputName(i.InputName) {
- imageName = fmt.Sprintf("%s%s", decomposedImage.transport, i.InputName)
+ if hasShaInInputName(inputName) {
+ imageName = fmt.Sprintf("%s%s", decomposedImage.transport, inputName)
} else {
imageName = decomposedImage.assembleWithTransport()
}
srcRef, err := alltransports.ParseImageName(imageName)
if err != nil {
- return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName)
+ return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
}
ps := pullRefName{
- image: i.InputName,
+ image: inputName,
srcRef: srcRef,
}
- if hasShaInInputName(i.InputName) {
+ if hasShaInInputName(inputName) {
ps.dstName = decomposedImage.assemble()
} else {
ps.dstName = ps.image
@@ -311,12 +311,12 @@ func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
for _, registry := range searchRegistries {
decomposedImage.registry = registry
imageName := decomposedImage.assembleWithTransport()
- if hasShaInInputName(i.InputName) {
- imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, i.InputName)
+ if hasShaInInputName(inputName) {
+ imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, inputName)
}
srcRef, err := alltransports.ParseImageName(imageName)
if err != nil {
- return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName)
+ return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
}
ps := pullRefName{
image: decomposedImage.assemble(),
@@ -332,7 +332,7 @@ func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
// refPairsFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
// image references to try pulling in combination with the registries.conf file as well
func (i *Image) refPairsFromPossiblyUnqualifiedName() ([]*pullRefPair, error) {
- refNames, err := i.refNamesFromPossiblyUnqualifiedName()
+ refNames, err := refNamesFromPossiblyUnqualifiedName(i.InputName)
if err != nil {
return nil, err
}