aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2020-02-07 01:55:30 +0100
committerMiloslav Trmač <mitr@redhat.com>2020-02-07 23:36:01 +0100
commitede412f40f662b506d1d7d44d51cd51ef5922f64 (patch)
tree461c183ba2615ed7d5fcefcc208678b1e5a57800 /libpod
parenta433b858d275557e1469fdcd917f1ef2a93011cd (diff)
downloadpodman-ede412f40f662b506d1d7d44d51cd51ef5922f64.tar.gz
podman-ede412f40f662b506d1d7d44d51cd51ef5922f64.tar.bz2
podman-ede412f40f662b506d1d7d44d51cd51ef5922f64.zip
Use Runtime.NewFromLocal instead of open-coded copies
All code creating an Image by looking up a name now uses Runtime.NewFromLocal. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/image.go27
1 files changed, 6 insertions, 21 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 432b8b848..db14eab18 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -146,14 +146,9 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
// We don't know if the image is local or not ... check local first
if pullType != util.PullImageAlways {
- newImage := Image{
- InputName: name,
- imageruntime: ir,
- }
- localImage, err := newImage.getLocalImage()
+ newImage, err := ir.NewFromLocal(name)
if err == nil {
- newImage.image = localImage
- return &newImage, nil
+ return newImage, nil
} else if pullType == util.PullImageNever {
return nil, err
}
@@ -168,16 +163,11 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile
return nil, errors.Wrapf(err, "unable to pull %s", name)
}
- newImage := Image{
- InputName: imageName[0],
- imageruntime: ir,
- }
- img, err := newImage.getLocalImage()
+ newImage, err := ir.NewFromLocal(imageName[0])
if err != nil {
return nil, errors.Wrapf(err, "error retrieving local image after pulling %s", name)
}
- newImage.image = img
- return &newImage, nil
+ return newImage, nil
}
// LoadFromArchiveReference creates a new image object for images pulled from a tar archive and the like (podman load)
@@ -194,16 +184,11 @@ func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.Im
}
for _, name := range imageNames {
- newImage := Image{
- InputName: name,
- imageruntime: ir,
- }
- img, err := newImage.getLocalImage()
+ newImage, err := ir.NewFromLocal(name)
if err != nil {
return nil, errors.Wrapf(err, "error retrieving local image after pulling %s", name)
}
- newImage.image = img
- newImages = append(newImages, &newImage)
+ newImages = append(newImages, newImage)
}
ir.newImageEvent(events.LoadFromArchive, "")
return newImages, nil