diff --git a/pkg/pod/entrypoint_lookup_impl.go b/pkg/pod/entrypoint_lookup_impl.go index 4943826e6b2..e95397343e8 100644 --- a/pkg/pod/entrypoint_lookup_impl.go +++ b/pkg/pod/entrypoint_lookup_impl.go @@ -139,6 +139,11 @@ func buildCommandMap(idx v1.ImageIndex, hasArgs bool) (map[string][]string, erro } for _, desc := range mf.Manifests { plat := desc.Platform.String() + // skip unknown platforms. + // Docker uses these to store attestation data: https://docs.docker.com/build/attestations/attestation-storage/#examples + if plat == "unknown/unknown" { + continue + } if got, found := platToDigest[plat]; found && got != desc.Digest { return nil, fmt.Errorf("duplicate unique image found for platform: %s: found %s and %s", plat, got, desc.Digest) } diff --git a/pkg/pod/entrypoint_lookup_impl_test.go b/pkg/pod/entrypoint_lookup_impl_test.go index f18e4a8fced..50620597b31 100644 --- a/pkg/pod/entrypoint_lookup_impl_test.go +++ b/pkg/pod/entrypoint_lookup_impl_test.go @@ -197,6 +197,7 @@ func TestBuildCommandMap(t *testing.T) { desc string idx v1.ImageIndex wantErr bool + want map[string][]string }{{ // Valid multi-platform image even though some platforms only differ by variant or osversion. desc: "valid index", @@ -226,6 +227,13 @@ func TestBuildCommandMap(t *testing.T) { Platform: &v1.Platform{OS: "windows", Architecture: "amd64", OSVersion: "4.5.6"}, }, }), + want: map[string][]string{ + "linux/amd64": nil, + "linux/arm64/7": nil, + "linux/arm64/8": nil, + "windows/amd64:1.2.3": nil, + "windows/amd64:4.5.6": nil, + }, }, { desc: "valid index, with dupes", idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{ @@ -239,6 +247,9 @@ func TestBuildCommandMap(t *testing.T) { Platform: &v1.Platform{OS: "linux", Architecture: "amd64"}, }, }), + want: map[string][]string{ + "linux/amd64": nil, + }, }, { desc: "invalid index, dupes with different digests", idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{ @@ -253,13 +264,41 @@ func TestBuildCommandMap(t *testing.T) { }, }), wantErr: true, + }, { + desc: "valid index, with unknown platform", + idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{ + Add: img, + Descriptor: v1.Descriptor{ + Platform: &v1.Platform{OS: "linux", Architecture: "amd64"}, + }, + }, mutate.IndexAddendum{ + Add: img, + Descriptor: v1.Descriptor{ + Platform: &v1.Platform{OS: "unknown", Architecture: "unknown"}, + }, + }), + want: map[string][]string{ + "linux/amd64": nil, + }, + }, { + desc: "valid index, only unknown platform", + idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{ + Add: img, + Descriptor: v1.Descriptor{ + Platform: &v1.Platform{OS: "unknown", Architecture: "unknown"}, + }, + }), + want: map[string][]string{}, }} { t.Run(c.desc, func(t *testing.T) { - _, err := buildCommandMap(c.idx, true) + got, err := buildCommandMap(c.idx, true) gotErr := (err != nil) if gotErr != c.wantErr { t.Fatalf("got err: %v, want err: %t", err, c.wantErr) } + if d := cmp.Diff(c.want, got); d != "" && !c.wantErr { + t.Errorf("Diff %s", diff.PrintWantGot(d)) + } }) } }