From 633501b1b7450676c47d891092b53680206b8398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 9 Jan 2019 21:01:56 +0100 Subject: [PATCH] Use getPullRefPair / getSinglePullRefPairGoal in pullGoalFromPossiblyUnqualifiedName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This shortens the code a bit, but most importantly ensures that all pulls from docker.Transport are processed exactly the same way, and there is only a single store.ParseStoreReference in the pull code. It's a bit wasteful to call decompose() in getPullRefPair just after pullGoalFromPossiblyUnqualifiedName has qualified the name, but on balance only having exactly one code path seems worth it. Alternatively we could split getPullRefPairToQualifiedDestination from getPullRefPair. Should not change behavior. Signed-off-by: Miloslav Trmač --- libpod/image/pull.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/libpod/image/pull.go b/libpod/image/pull.go index af6b84c34b..434b835201 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -283,16 +283,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG if err != nil { return nil, errors.Wrapf(err, "unable to parse '%s'", inputName) } - destRef, err := is.Transport.ParseStoreReference(ir.store, inputName) - if err != nil { - return nil, errors.Wrapf(err, "error parsing dest reference name %#v", inputName) - } - ps := pullRefPair{ - image: inputName, - srcRef: srcRef, - dstRef: destRef, - } - return singlePullRefPairGoal(ps), nil + return ir.getSinglePullRefPairGoal(srcRef, inputName) } searchRegistries, err := registries.GetRegistries() @@ -310,13 +301,9 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG if err != nil { return nil, errors.Wrapf(err, "unable to parse '%s'", imageName) } - ps := pullRefPair{ - image: imageName, - srcRef: srcRef, - } - ps.dstRef, err = is.Transport.ParseStoreReference(ir.store, ps.image) + ps, err := ir.getPullRefPair(srcRef, imageName) if err != nil { - return nil, errors.Wrapf(err, "error parsing dest reference name %#v", ps.image) + return nil, err } refPairs = append(refPairs, ps) }