mirror of
https://github.com/containers/podman.git
synced 2025-06-26 21:07:02 +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
|
||||
// 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user