Merge pull request #816 from rhatdan/pull

If we tell system to never pull we should not pull
This commit is contained in:
OpenShift Merge Robot 2021-12-02 10:42:47 +01:00 committed by GitHub
commit 15e9f196bc
2 changed files with 21 additions and 1 deletions

View File

@ -454,7 +454,7 @@ func (r *Runtime) copySingleImageFromRegistry(ctx context.Context, imageName str
// NOTE that this is will even override --pull={false,never}. This is
// very likely a bug but a consistent one in Podman/Buildah and should
// be addressed at a later point.
if pullPolicy != config.PullPolicyAlways {
if pullPolicy != config.PullPolicyAlways && pullPolicy != config.PullPolicyNever {
switch {
// User input clearly refer to a local image.
case strings.HasPrefix(imageName, "localhost/"):

View File

@ -122,3 +122,23 @@ func TestPullPlatforms(t *testing.T) {
require.NoError(t, err, "lookup busybox - by arm")
require.NotNil(t, image, "lookup busybox - by local arch")
}
func TestPullPolicy(t *testing.T) {
runtime, cleanup := testNewRuntime(t)
defer cleanup()
ctx := context.Background()
pullOptions := &PullOptions{}
pulledImages, err := runtime.Pull(ctx, "alpine", config.PullPolicyNever, pullOptions)
require.Error(t, err, "Never pull different arch alpine")
require.Nil(t, pulledImages, "lookup alpine")
pulledImages, err = runtime.Pull(ctx, "alpine", config.PullPolicyNewer, pullOptions)
require.NoError(t, err, "Newer pull different arch alpine")
require.NotNil(t, pulledImages, "lookup alpine")
pulledImages, err = runtime.Pull(ctx, "alpine", config.PullPolicyNever, pullOptions)
require.NoError(t, err, "Never pull different arch alpine")
require.NotNil(t, pulledImages, "lookup alpine")
}