mirror of
https://github.com/containers/podman.git
synced 2025-06-26 21:07:02 +08:00
Use []pullRefPair instead of []*pullRefPair
We are passing the values, don't really need the pointer sharing semantics, and the structures are small enough, and the arrays short enough, that we very likely lose on the indirect accesses more than we save on quicker copying of the slices when extending them. Value semantics is safer anyway. 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
dae6200662
commit
bf0ab88eac
@ -165,7 +165,7 @@ func refNamesFromImageReference(ctx context.Context, srcRef types.ImageReference
|
|||||||
}
|
}
|
||||||
|
|
||||||
// refPairsFromImageReference returns a list of pullRefPair for a single ImageReference, depending on the used transport.
|
// refPairsFromImageReference returns a list of pullRefPair for a single ImageReference, depending on the used transport.
|
||||||
func (ir *Runtime) refPairsFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) ([]*pullRefPair, error) {
|
func (ir *Runtime) refPairsFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) ([]pullRefPair, error) {
|
||||||
refNames, err := refNamesFromImageReference(ctx, srcRef, imgName, sc)
|
refNames, err := refNamesFromImageReference(ctx, srcRef, imgName, sc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -179,7 +179,7 @@ func (ir *Runtime) refPairsFromImageReference(ctx context.Context, srcRef types.
|
|||||||
// pulled.
|
// pulled.
|
||||||
func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signaturePolicyPath string, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) {
|
func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signaturePolicyPath string, signingOptions SigningOptions, dockerOptions *DockerRegistryOptions, forceSecure bool) ([]string, error) {
|
||||||
// pullImage copies the image from the source to the destination
|
// pullImage copies the image from the source to the destination
|
||||||
var pullRefPairs []*pullRefPair
|
var pullRefPairs []pullRefPair
|
||||||
sc := GetSystemContext(signaturePolicyPath, authfile, false)
|
sc := GetSystemContext(signaturePolicyPath, authfile, false)
|
||||||
srcRef, err := alltransports.ParseImageName(i.InputName)
|
srcRef, err := alltransports.ParseImageName(i.InputName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -317,7 +317,7 @@ func refNamesFromPossiblyUnqualifiedName(inputName string) ([]pullRefName, error
|
|||||||
|
|
||||||
// refPairsFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
|
// refPairsFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
|
||||||
// image references to try pulling in combination with the registries.conf file as well
|
// image references to try pulling in combination with the registries.conf file as well
|
||||||
func (i *Image) refPairsFromPossiblyUnqualifiedName() ([]*pullRefPair, error) {
|
func (i *Image) refPairsFromPossiblyUnqualifiedName() ([]pullRefPair, error) {
|
||||||
refNames, err := refNamesFromPossiblyUnqualifiedName(i.InputName)
|
refNames, err := refNamesFromPossiblyUnqualifiedName(i.InputName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -325,16 +325,16 @@ func (i *Image) refPairsFromPossiblyUnqualifiedName() ([]*pullRefPair, error) {
|
|||||||
return i.imageruntime.pullRefPairsFromRefNames(refNames)
|
return i.imageruntime.pullRefPairsFromRefNames(refNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pullRefPairsFromNames converts a []pullRefName to []*pullRefPair
|
// pullRefPairsFromNames converts a []pullRefName to []pullRefPair
|
||||||
func (ir *Runtime) pullRefPairsFromRefNames(refNames []pullRefName) ([]*pullRefPair, error) {
|
func (ir *Runtime) pullRefPairsFromRefNames(refNames []pullRefName) ([]pullRefPair, error) {
|
||||||
// Here we construct the destination references
|
// Here we construct the destination references
|
||||||
res := make([]*pullRefPair, len(refNames))
|
res := make([]pullRefPair, len(refNames))
|
||||||
for i, rn := range refNames {
|
for i, rn := range refNames {
|
||||||
destRef, err := is.Transport.ParseStoreReference(ir.store, rn.dstName)
|
destRef, err := is.Transport.ParseStoreReference(ir.store, rn.dstName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error parsing dest reference name %#v", rn.dstName)
|
return nil, errors.Wrapf(err, "error parsing dest reference name %#v", rn.dstName)
|
||||||
}
|
}
|
||||||
res[i] = &pullRefPair{
|
res[i] = pullRefPair{
|
||||||
image: rn.image,
|
image: rn.image,
|
||||||
srcRef: rn.srcRef,
|
srcRef: rn.srcRef,
|
||||||
dstRef: destRef,
|
dstRef: destRef,
|
||||||
|
Reference in New Issue
Block a user