summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 06:05:53 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:59 +0000
commit1efbc40999485d3bc4fc678a424d3b4ee6341c61 (patch)
tree8a66f92343b0683a4021491f44a0ad71f9deb65d
parent4dab4d97de57759e62bb37ad5d47743e7e0e4b12 (diff)
downloadpodman-1efbc40999485d3bc4fc678a424d3b4ee6341c61.tar.gz
podman-1efbc40999485d3bc4fc678a424d3b4ee6341c61.tar.bz2
podman-1efbc40999485d3bc4fc678a424d3b4ee6341c61.zip
Use an early return from refNamesFromPossiblyUnqualifiedName
We will introduce helpers for the "single image" case, and having a separate return statement will make them applicable here. (Also allows us to reduce the scope of some variables a bit.) Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
-rw-r--r--libpod/image/pull.go46
1 files changed, 21 insertions, 25 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 060bab82a..cfddb7e8d 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -259,16 +259,12 @@ 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 refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, error) {
- var (
- pullNames []*pullRefName
- imageName string
- )
-
decomposedImage, err := decompose(inputName)
if err != nil {
return nil, err
}
if decomposedImage.hasRegistry {
+ var imageName string
if hasShaInInputName(inputName) {
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, inputName)
} else {
@@ -287,30 +283,30 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, erro
} else {
ps.dstName = ps.image
}
- pullNames = append(pullNames, &ps)
+ return []*pullRefName{&ps}, nil
+ }
- } else {
- searchRegistries, err := registries.GetRegistries()
+ searchRegistries, err := registries.GetRegistries()
+ if err != nil {
+ return nil, err
+ }
+ var pullNames []*pullRefName
+ for _, registry := range searchRegistries {
+ decomposedImage.registry = registry
+ imageName := decomposedImage.assembleWithTransport()
+ if hasShaInInputName(inputName) {
+ imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, inputName)
+ }
+ srcRef, err := alltransports.ParseImageName(imageName)
if err != nil {
- return nil, err
+ return nil, errors.Wrapf(err, "unable to parse '%s'", inputName)
}
- for _, registry := range searchRegistries {
- decomposedImage.registry = registry
- imageName := decomposedImage.assembleWithTransport()
- 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'", inputName)
- }
- ps := pullRefName{
- image: decomposedImage.assemble(),
- srcRef: srcRef,
- }
- ps.dstName = ps.image
- pullNames = append(pullNames, &ps)
+ ps := pullRefName{
+ image: decomposedImage.assemble(),
+ srcRef: srcRef,
}
+ ps.dstName = ps.image
+ pullNames = append(pullNames, &ps)
}
return pullNames, nil
}