summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-08-01 23:46:35 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-02 13:17:17 +0000
commit682076e58f78fccc1a5a4561ce71dfcf60880699 (patch)
treebf60120e933783e65078522ed09de881834dab3b /libpod
parent4cf9308bf25ce172b89bc6dc6a5a328dc3b254d5 (diff)
downloadpodman-682076e58f78fccc1a5a4561ce71dfcf60880699.tar.gz
podman-682076e58f78fccc1a5a4561ce71dfcf60880699.tar.bz2
podman-682076e58f78fccc1a5a4561ce71dfcf60880699.zip
Inline pullGoalNamesFromImageReference back into Runtime.pullGoalFromImageReference
Now that we don't need a separate pullGoalNamesFromImageReference for running tests, inline it back. This forces us to add some glue code to getSinglePullRefNameGoal and to convert between pullGoal and *pullGoal; that is temporary and will be cleaned up soon. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1198 Approved by: mheon
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/pull.go46
1 files changed, 23 insertions, 23 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 7d5bd4727..b7b347475 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -108,13 +108,18 @@ func getPullRefName(srcRef types.ImageReference, destName string) pullRefName {
}
// getSinglePullRefNameGoal calls getPullRefName with the specified parameters, and returns a single-pair goal for the return value.
-func getSinglePullRefNameGoal(srcRef types.ImageReference, destName string) (*pullGoalNames, error) {
+func (ir *Runtime) getSinglePullRefNameGoal(srcRef types.ImageReference, destName string) (*pullGoal, error) {
rn := getPullRefName(srcRef, destName)
- return singlePullRefNameGoal(rn), nil
+ goalNames := singlePullRefNameGoal(rn)
+ goal, err := ir.pullGoalFromGoalNames(goalNames)
+ if err != nil {
+ return nil, err
+ }
+ return &goal, nil
}
-// pullGoalNamesFromImageReference returns a pullGoalNames for a single ImageReference, depending on the used transport.
-func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) (*pullGoalNames, error) {
+// pullGoalFromImageReference returns a pull goal for a single ImageReference, depending on the used transport.
+func (ir *Runtime) pullGoalFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) (*pullGoal, error) {
// supports pulling from docker-archive, oci, and registries
switch srcRef.Transport().Name() {
case DockerArchive:
@@ -135,7 +140,7 @@ func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageRefe
if err != nil {
return nil, err
}
- return getSinglePullRefNameGoal(srcRef, reference)
+ return ir.getSinglePullRefNameGoal(srcRef, reference)
}
if len(manifest[0].RepoTags) == 0 {
@@ -144,7 +149,7 @@ func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageRefe
if err != nil {
return nil, err
}
- return getSinglePullRefNameGoal(srcRef, digest)
+ return ir.getSinglePullRefNameGoal(srcRef, digest)
}
// Need to load in all the repo tags from the manifest
@@ -153,12 +158,16 @@ func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageRefe
pullInfo := getPullRefName(srcRef, dst)
res = append(res, pullInfo)
}
- return &pullGoalNames{
+ goal, err := ir.pullGoalFromGoalNames(&pullGoalNames{
refNames: res,
pullAllPairs: true,
usedSearchRegistries: false,
searchedRegistries: nil,
- }, nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ return &goal, nil
case OCIArchive:
// retrieve the manifest from index.json to access the image name
@@ -178,7 +187,7 @@ func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageRefe
} else {
dest = manifest.Annotations["org.opencontainers.image.ref.name"]
}
- return getSinglePullRefNameGoal(srcRef, dest)
+ return ir.getSinglePullRefNameGoal(srcRef, dest)
case DirTransport:
path := srcRef.StringWithinTransport()
@@ -189,21 +198,11 @@ func pullGoalNamesFromImageReference(ctx context.Context, srcRef types.ImageRefe
// so docker.io isn't prepended, and the path becomes the repository
image = DefaultLocalRepo + image
}
- return getSinglePullRefNameGoal(srcRef, image)
+ return ir.getSinglePullRefNameGoal(srcRef, image)
default:
- return getSinglePullRefNameGoal(srcRef, imgName)
- }
-}
-
-// pullGoalFromImageReference returns a pull goal for a single ImageReference, depending on the used transport.
-func (ir *Runtime) pullGoalFromImageReference(ctx context.Context, srcRef types.ImageReference, imgName string, sc *types.SystemContext) (pullGoal, error) {
- goalNames, err := pullGoalNamesFromImageReference(ctx, srcRef, imgName, sc)
- if err != nil {
- return pullGoal{}, err
+ return ir.getSinglePullRefNameGoal(srcRef, imgName)
}
-
- return ir.pullGoalFromGoalNames(goalNames)
}
// pullImageFromHeuristicSource pulls an image based on inputName, which is heuristically parsed and may involve configured registries.
@@ -219,10 +218,11 @@ func (ir *Runtime) pullImageFromHeuristicSource(ctx context.Context, inputName s
return nil, errors.Wrap(err, "error getting default registries to try")
}
} else {
- goal, err = ir.pullGoalFromImageReference(ctx, srcRef, inputName, sc)
+ g, err := ir.pullGoalFromImageReference(ctx, srcRef, inputName, sc)
if err != nil {
return nil, errors.Wrapf(err, "error determining pull goal for image %q", inputName)
}
+ goal = *g
}
return ir.doPullImage(ctx, sc, goal, writer, signingOptions, dockerOptions, forceSecure)
}
@@ -234,7 +234,7 @@ func (ir *Runtime) pullImageFromReference(ctx context.Context, srcRef types.Imag
if err != nil {
return nil, errors.Wrapf(err, "error determining pull goal for image %q", transports.ImageName(srcRef))
}
- return ir.doPullImage(ctx, sc, goal, writer, signingOptions, dockerOptions, forceSecure)
+ return ir.doPullImage(ctx, sc, *goal, writer, signingOptions, dockerOptions, forceSecure)
}
// doPullImage is an internal helper interpreting pullGoal. Almost everyone should call one of the callers of doPullImage instead.