summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 05:59:13 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:59 +0000
commit83f40de9652712baf84379f3292dc4f4f103ce50 (patch)
tree977e78f842c95baa4e6b4006b97eea75e5a4810d /libpod/image
parent1efbc40999485d3bc4fc678a424d3b4ee6341c61 (diff)
downloadpodman-83f40de9652712baf84379f3292dc4f4f103ce50.tar.gz
podman-83f40de9652712baf84379f3292dc4f4f103ce50.tar.bz2
podman-83f40de9652712baf84379f3292dc4f4f103ce50.zip
Introduce singlePullRefNameGoal
All but two cases returning a []*pullRefName only return a single item. Introduce a helper for that case, which seems not worth it now, but the return value will get a bit more complex and introducing the helper now will minimize code changes in future commits. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/pull.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index cfddb7e8d..276ccc898 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -62,6 +62,10 @@ type pullRefName struct {
dstName string
}
+func singlePullRefNameGoal(rn *pullRefName) []*pullRefName {
+ return []*pullRefName{rn}
+}
+
func getPullRefName(srcRef types.ImageReference, destName string) *pullRefName {
imgPart, err := decompose(destName)
if err == nil && !imgPart.hasRegistry {
@@ -104,7 +108,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
if err != nil {
return nil, err
}
- return []*pullRefName{getPullRefName(srcRef, reference)}, nil
+ return singlePullRefNameGoal(getPullRefName(srcRef, reference)), nil
}
if len(manifest[0].RepoTags) == 0 {
@@ -113,7 +117,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
if err != nil {
return nil, err
}
- return []*pullRefName{getPullRefName(srcRef, digest)}, nil
+ return singlePullRefNameGoal(getPullRefName(srcRef, digest)), nil
}
// Need to load in all the repo tags from the manifest
@@ -142,7 +146,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
} else {
dest = manifest.Annotations["org.opencontainers.image.ref.name"]
}
- return []*pullRefName{getPullRefName(srcRef, dest)}, nil
+ return singlePullRefNameGoal(getPullRefName(srcRef, dest)), nil
case DirTransport:
path := srcRef.StringWithinTransport()
@@ -153,10 +157,10 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
// so docker.io isn't prepended, and the path becomes the repository
image = DefaultLocalRepo + image
}
- return []*pullRefName{getPullRefName(srcRef, image)}, nil
+ return singlePullRefNameGoal(getPullRefName(srcRef, image)), nil
default:
- return []*pullRefName{getPullRefName(srcRef, imgName)}, nil
+ return singlePullRefNameGoal(getPullRefName(srcRef, imgName)), nil
}
}
@@ -283,7 +287,7 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, erro
} else {
ps.dstName = ps.image
}
- return []*pullRefName{&ps}, nil
+ return singlePullRefNameGoal(&ps), nil
}
searchRegistries, err := registries.GetRegistries()