diff options
author | Brent Baude <bbaude@redhat.com> | 2020-01-27 11:53:39 -0600 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-01-28 13:36:10 -0600 |
commit | 31a1f44fe6934c6247f7bf2f5774805b263da660 (patch) | |
tree | a818496c7612b310d0b651fcc954d23df802a6c4 /pkg/adapter/pods.go | |
parent | d07c26310697d8874219731c6c42f6d0d0330e87 (diff) | |
download | podman-31a1f44fe6934c6247f7bf2f5774805b263da660.tar.gz podman-31a1f44fe6934c6247f7bf2f5774805b263da660.tar.bz2 podman-31a1f44fe6934c6247f7bf2f5774805b263da660.zip |
honor pull policy in play kube
When a container specification has a pull policy, we should honor it when recreating the pods/containers from yaml. furthermore, ini kube, if a tag is :latest, then the always pull policy is automatically instituted.
Fixes: #4880
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/adapter/pods.go')
-rw-r--r-- | pkg/adapter/pods.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index f89fc7011..b0e63f770 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/containers/buildah/pkg/parse" + "github.com/containers/image/v5/docker/reference" "github.com/containers/image/v5/types" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/shared" @@ -604,7 +605,24 @@ func (r *LocalRuntime) PlayKubeYAML(ctx context.Context, c *cliconfig.KubePlayVa } for _, container := range podYAML.Spec.Containers { - newImage, err := r.ImageRuntime().New(ctx, container.Image, c.SignaturePolicy, c.Authfile, writer, &dockerRegistryOptions, image.SigningOptions{}, nil, util.PullImageMissing) + pullPolicy := util.PullImageMissing + if len(container.ImagePullPolicy) > 0 { + pullPolicy, err = util.ValidatePullType(string(container.ImagePullPolicy)) + if err != nil { + return nil, err + } + } + named, err := reference.ParseNormalizedNamed(container.Image) + if err != nil { + return nil, err + } + // In kube, if the image is tagged with latest, it should always pull + if tagged, isTagged := named.(reference.NamedTagged); isTagged { + if tagged.Tag() == image.LatestTag { + pullPolicy = util.PullImageAlways + } + } + newImage, err := r.ImageRuntime().New(ctx, container.Image, c.SignaturePolicy, c.Authfile, writer, &dockerRegistryOptions, image.SigningOptions{}, nil, pullPolicy) if err != nil { return nil, err } |