summaryrefslogtreecommitdiff
path: root/pkg/adapter
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-01-27 11:53:39 -0600
committerBrent Baude <bbaude@redhat.com>2020-01-28 13:36:10 -0600
commit31a1f44fe6934c6247f7bf2f5774805b263da660 (patch)
treea818496c7612b310d0b651fcc954d23df802a6c4 /pkg/adapter
parentd07c26310697d8874219731c6c42f6d0d0330e87 (diff)
downloadpodman-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')
-rw-r--r--pkg/adapter/pods.go20
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
}