summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-18 23:20:36 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-23 12:44:38 +0000
commit775eb78f6ba96a19f16e2f96fc7d2ee402049a3b (patch)
tree7577ad8e62eebd604549bf4ed67c51233c7f4e0f /libpod/image
parent70589c326c2da7616ff0c4def8792130543ff383 (diff)
downloadpodman-775eb78f6ba96a19f16e2f96fc7d2ee402049a3b.tar.gz
podman-775eb78f6ba96a19f16e2f96fc7d2ee402049a3b.tar.bz2
podman-775eb78f6ba96a19f16e2f96fc7d2ee402049a3b.zip
Introduce nameToPull, move shaPullName in there
shaPullName is only used internally in createNamesToPull; so, introduce a nameToPull as a variant of pullStruct which has shaPullName (and does not have destRef). Eventually, we want to split pullStruct preparation into easily-testable store-independent name preparation, and a store-dependent and difficult-to-test but trivial conversion using StorageTransport.ParseStoreReference. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/pull.go35
1 files changed, 23 insertions, 12 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index cb2de8fc2..f1bfac2a3 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -50,11 +50,11 @@ var (
DefaultLocalRepo = "localhost"
)
+// pullStruct records a pair of prepared image references to try to pull (if not DockerArchive) or to pull all (if DockerArchive)
type pullStruct struct {
- image string
- srcRef types.ImageReference
- dstRef types.ImageReference
- shaPullName string
+ image string
+ srcRef types.ImageReference
+ dstRef types.ImageReference
}
func (ir *Runtime) getPullStruct(srcRef types.ImageReference, destName string) (*pullStruct, error) {
@@ -257,11 +257,18 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa
return images, nil
}
+// 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
+}
+
// createNamesToPull looks at a decomposed image and determines the possible
// images names to try pulling in combination with the registries.conf file as well
func (i *Image) createNamesToPull() ([]*pullStruct, error) {
var (
- pullNames []*pullStruct
+ pullNames []*nameToPull
imageName string
)
@@ -279,7 +286,7 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) {
if err != nil {
return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName)
}
- ps := pullStruct{
+ ps := nameToPull{
image: i.InputName,
srcRef: srcRef,
}
@@ -303,7 +310,7 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) {
if err != nil {
return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName)
}
- ps := pullStruct{
+ ps := nameToPull{
image: decomposedImage.assemble(),
srcRef: srcRef,
}
@@ -311,8 +318,9 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) {
}
}
- // Here we construct the destination reference
- for _, pStruct := range pullNames {
+ // 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
@@ -321,8 +329,11 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) {
if err != nil {
return nil, errors.Wrapf(err, "error parsing dest reference name")
}
- pStruct.dstRef = destRef
+ res[j] = &pullStruct{
+ image: pStruct.image,
+ srcRef: pStruct.srcRef,
+ dstRef: destRef,
+ }
}
-
- return pullNames, nil
+ return res, nil
}