diff --git a/common/libimage/pull.go b/common/libimage/pull.go index 1d1bc201b6..59221d935c 100644 --- a/common/libimage/pull.go +++ b/common/libimage/pull.go @@ -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/"): diff --git a/common/libimage/pull_test.go b/common/libimage/pull_test.go index c3e2c17071..cdc34b2504 100644 --- a/common/libimage/pull_test.go +++ b/common/libimage/pull_test.go @@ -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") + +}