summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-04-14 15:34:48 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-14 23:55:24 +0000
commitfa8442e4a063b9a074cd2d17effdf5de138f90cb (patch)
tree9bf00bed67a58ad35c9eb7ac6f176e3bb48fa4fd /libpod/image
parent62b59df053357f040d85c26727734815046e2bc3 (diff)
downloadpodman-fa8442e4a063b9a074cd2d17effdf5de138f90cb.tar.gz
podman-fa8442e4a063b9a074cd2d17effdf5de138f90cb.tar.bz2
podman-fa8442e4a063b9a074cd2d17effdf5de138f90cb.zip
podman pull should always try to pull
In the case where you have an image local, if the the user runs podman pull, we should always attempt to pull an updated image. Added a forceRemote bool to New (image) so we can differentiate between "pull" or run because the actions differ. Run does not need to pull the latest -- only run. Signed-off-by: baude <bbaude@redhat.com> Closes: #618 Approved by: baude
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/image.go14
-rw-r--r--libpod/image/image_test.go8
2 files changed, 12 insertions, 10 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 009c51886..89da71cb6 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -117,18 +117,20 @@ func (ir *Runtime) NewFromLocal(name string) (*Image, error) {
// New creates a new image object where the image could be local
// or remote
-func (ir *Runtime) New(name, signaturePolicyPath, authfile string, writer io.Writer, dockeroptions *DockerRegistryOptions, signingoptions SigningOptions) (*Image, error) {
+func (ir *Runtime) New(name, signaturePolicyPath, authfile string, writer io.Writer, dockeroptions *DockerRegistryOptions, signingoptions SigningOptions, forcePull bool) (*Image, error) {
// We don't know if the image is local or not ... check local first
newImage := Image{
InputName: name,
Local: false,
imageruntime: ir,
}
- localImage, err := newImage.getLocalImage()
- if err == nil {
- newImage.Local = true
- newImage.image = localImage
- return &newImage, nil
+ if !forcePull {
+ localImage, err := newImage.getLocalImage()
+ if err == nil {
+ newImage.Local = true
+ newImage.image = localImage
+ return &newImage, nil
+ }
}
// The image is not local
diff --git a/libpod/image/image_test.go b/libpod/image/image_test.go
index cb32b6cae..8c1138f71 100644
--- a/libpod/image/image_test.go
+++ b/libpod/image/image_test.go
@@ -81,9 +81,9 @@ func TestImage_NewFromLocal(t *testing.T) {
// Need images to be present for this test
ir, err := NewImageRuntimeFromOptions(so)
assert.NoError(t, err)
- bb, err := ir.New("docker.io/library/busybox:latest", "", "", writer, nil, SigningOptions{})
+ bb, err := ir.New("docker.io/library/busybox:latest", "", "", writer, nil, SigningOptions{}, false)
assert.NoError(t, err)
- bbglibc, err := ir.New("docker.io/library/busybox:glibc", "", "", writer, nil, SigningOptions{})
+ bbglibc, err := ir.New("docker.io/library/busybox:glibc", "", "", writer, nil, SigningOptions{}, false)
assert.NoError(t, err)
tm, err := makeLocalMatrix(bb, bbglibc)
@@ -126,7 +126,7 @@ func TestImage_New(t *testing.T) {
// Iterate over the names and delete the image
// after the pull
for _, img := range names {
- newImage, err := ir.New(img, "", "", writer, nil, SigningOptions{})
+ newImage, err := ir.New(img, "", "", writer, nil, SigningOptions{}, false)
assert.NoError(t, err)
assert.NotEqual(t, newImage.ID(), "")
err = newImage.Remove(false)
@@ -150,7 +150,7 @@ func TestImage_MatchRepoTag(t *testing.T) {
}
ir, err := NewImageRuntimeFromOptions(so)
assert.NoError(t, err)
- newImage, err := ir.New("busybox", "", "", os.Stdout, nil, SigningOptions{})
+ newImage, err := ir.New("busybox", "", "", os.Stdout, nil, SigningOptions{}, false)
assert.NoError(t, err)
err = newImage.TagImage("foo:latest")
assert.NoError(t, err)