mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
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
This commit is contained in:
parent
1efbc40999
commit
83f40de965
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue