From 729e72ef484fb7853282184608007bad017ae943 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Wed, 18 Jul 2018 23:27:48 +0200 Subject: Replace optional nameToPull.shaPullName with mandatory dstName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This consolidates the shaPullName logic into a single place, (and eliminates the unclear shaPullName member name completely). The resulting nameToPull will shortly be more generally useful. Should not change behavior. Signed-off-by: Miloslav Trmač Closes: #1112 Approved by: rhatdan --- libpod/image/pull.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libpod') diff --git a/libpod/image/pull.go b/libpod/image/pull.go index f1bfac2a3..c9bcb19e5 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -259,9 +259,9 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa // nameToPull is a mapping between a resolved source and an expected store destination name (FIXME: clean up somehow?) type nameToPull struct { - image string - srcRef types.ImageReference - shaPullName string + image string + srcRef types.ImageReference + dstName string } // createNamesToPull looks at a decomposed image and determines the possible @@ -291,7 +291,9 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) { srcRef: srcRef, } if i.HasShaInInputName() { - ps.shaPullName = decomposedImage.assemble() + ps.dstName = decomposedImage.assemble() + } else { + ps.dstName = ps.image } pullNames = append(pullNames, &ps) @@ -314,6 +316,7 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) { image: decomposedImage.assemble(), srcRef: srcRef, } + ps.dstName = ps.image pullNames = append(pullNames, &ps) } } @@ -321,11 +324,7 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) { // Here we construct the destination references res := make([]*pullStruct, len(pullNames)) for j, pStruct := range pullNames { - dstName := pStruct.image - if pStruct.shaPullName != "" { - dstName = pStruct.shaPullName - } - destRef, err := is.Transport.ParseStoreReference(i.imageruntime.store, dstName) + destRef, err := is.Transport.ParseStoreReference(i.imageruntime.store, pStruct.dstName) if err != nil { return nil, errors.Wrapf(err, "error parsing dest reference name") } -- cgit v1.2.3-54-g00ecf