diff options
author | Miloslav Trmač <mitr@redhat.com> | 2018-07-28 06:25:23 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-01 18:22:59 +0000 |
commit | 5eac0740c3d57150af39a3da26fb680744213bd1 (patch) | |
tree | bdcdfe5a151a2ec25a9ca1127bb97440358d8bbe /libpod/image/pull.go | |
parent | 86491efea0fcf5ab9e76668b1dadf004a74c62e0 (diff) | |
download | podman-5eac0740c3d57150af39a3da26fb680744213bd1.tar.gz podman-5eac0740c3d57150af39a3da26fb680744213bd1.tar.bz2 podman-5eac0740c3d57150af39a3da26fb680744213bd1.zip |
Eliminate the "DockerArchive means pull all refPairs" special case
Instead, encode it explicitly in pullGoal.pullAllPairs.
Should not change behavior (but does not add unit tests for
all of it).
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #1176
Approved by: rhatdan
Diffstat (limited to 'libpod/image/pull.go')
-rw-r--r-- | libpod/image/pull.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go index 0d1299c81..26f18691f 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -48,7 +48,7 @@ var ( DefaultLocalRepo = "localhost" ) -// pullRefPair records a pair of prepared image references to try to pull (if not DockerArchive) or to pull all (if DockerArchive) +// pullRefPair records a pair of prepared image references to pull. type pullRefPair struct { image string srcRef types.ImageReference @@ -57,10 +57,11 @@ type pullRefPair struct { // pullGoal represents the prepared image references and decided behavior to be executed by imagePull type pullGoal struct { - refPairs []pullRefPair + refPairs []pullRefPair + pullAllPairs bool // Pull all refPairs instead of stopping on first success. } -// pullRefName records a prepared source reference and a destination name to try to pull (if not DockerArchive) or to pull all (if DockerArchive) +// pullRefName records a prepared source reference and a destination name to pull. type pullRefName struct { image string srcRef types.ImageReference @@ -69,11 +70,15 @@ type pullRefName struct { // pullGoalNames is an intermediate variant of pullGoal which uses pullRefName instead of pullRefPair. type pullGoalNames struct { - refNames []pullRefName + refNames []pullRefName + pullAllPairs bool // Pull all refNames instead of stopping on first success. } func singlePullRefNameGoal(rn pullRefName) *pullGoalNames { - return &pullGoalNames{refNames: []pullRefName{rn}} + return &pullGoalNames{ + refNames: []pullRefName{rn}, + pullAllPairs: false, // Does not really make a difference. + } } func getPullRefName(srcRef types.ImageReference, destName string) pullRefName { @@ -137,7 +142,8 @@ func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageRefe res = append(res, pullInfo) } return &pullGoalNames{ - refNames: res, + refNames: res, + pullAllPairs: true, }, nil case OCIArchive: @@ -241,7 +247,7 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa io.WriteString(writer, "Failed\n") } } else { - if imageInfo.srcRef.Transport().Name() != DockerArchive { + if !goal.pullAllPairs { return []string{imageInfo.image}, nil } images = append(images, imageInfo.image) @@ -325,7 +331,8 @@ func pullGoalNamesFromPossiblyUnqualifiedName(inputName string) (*pullGoalNames, pullNames = append(pullNames, ps) } return &pullGoalNames{ - refNames: pullNames, + refNames: pullNames, + pullAllPairs: false, }, nil } @@ -357,5 +364,8 @@ func (ir *Runtime) pullGoalFromGoalNames(goalNames *pullGoalNames) (pullGoal, er dstRef: destRef, } } - return pullGoal{refPairs: res}, nil + return pullGoal{ + refPairs: res, + pullAllPairs: goalNames.pullAllPairs, + }, nil } |