mirror of
https://github.com/containers/podman.git
synced 2025-06-27 05:26:50 +08:00
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
This commit is contained in:

committed by
Atomic Bot

parent
4dab4d97de
commit
1efbc40999
@ -259,16 +259,12 @@ func hasShaInInputName(inputName string) bool {
|
|||||||
// refNamesFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
|
// refNamesFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
|
||||||
// image names to try pulling in combination with the registries.conf file as well
|
// image names to try pulling in combination with the registries.conf file as well
|
||||||
func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, error) {
|
func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, error) {
|
||||||
var (
|
|
||||||
pullNames []*pullRefName
|
|
||||||
imageName string
|
|
||||||
)
|
|
||||||
|
|
||||||
decomposedImage, err := decompose(inputName)
|
decomposedImage, err := decompose(inputName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if decomposedImage.hasRegistry {
|
if decomposedImage.hasRegistry {
|
||||||
|
var imageName string
|
||||||
if hasShaInInputName(inputName) {
|
if hasShaInInputName(inputName) {
|
||||||
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, inputName)
|
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, inputName)
|
||||||
} else {
|
} else {
|
||||||
@ -287,13 +283,14 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, erro
|
|||||||
} else {
|
} else {
|
||||||
ps.dstName = ps.image
|
ps.dstName = ps.image
|
||||||
}
|
}
|
||||||
pullNames = append(pullNames, &ps)
|
return []*pullRefName{&ps}, nil
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
searchRegistries, err := registries.GetRegistries()
|
searchRegistries, err := registries.GetRegistries()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var pullNames []*pullRefName
|
||||||
for _, registry := range searchRegistries {
|
for _, registry := range searchRegistries {
|
||||||
decomposedImage.registry = registry
|
decomposedImage.registry = registry
|
||||||
imageName := decomposedImage.assembleWithTransport()
|
imageName := decomposedImage.assembleWithTransport()
|
||||||
@ -311,7 +308,6 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]*pullRefName, erro
|
|||||||
ps.dstName = ps.image
|
ps.dstName = ps.image
|
||||||
pullNames = append(pullNames, &ps)
|
pullNames = append(pullNames, &ps)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return pullNames, nil
|
return pullNames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user