exporter: normalize annotation platforms

Normalize platform selectors in annotation keys to match exported image
platforms. Explicit linux/arm64/v8 selectors otherwise miss linux/arm64
images, silently dropping manifest and descriptor annotations.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax committed 2026-10-05 16:55:22 +02:00
1 parent 106f55ce1f
commit 37c5d2afe7
3 files changed
+42 -9

No files matched your search

+9 -9
View File
@@ -426,13 +426,13 @@ func testExportAnnotations(t *testing.T, sb integration.Sandbox) {
"name": target,
"push": "true",
"annotation-index.gio": "generic index opt",
"annotation-index." + ocispecs.AnnotationCreated: created,
"annotation-manifest.gmo": "generic manifest opt",
"annotation-manifest-descriptor.gmdo": "generic manifest descriptor opt",
"annotation-manifest[linux/amd64].mo": "amd64 manifest opt",
"annotation-manifest-descriptor[linux/amd64].mdo": "amd64 manifest descriptor opt",
"annotation-manifest[linux/arm64].mo": "arm64 manifest opt",
"annotation-manifest-descriptor[linux/arm64].mdo": "arm64 manifest descriptor opt",
"annotation-index." + ocispecs.AnnotationCreated: created,
"annotation-manifest.gmo": "generic manifest opt",
"annotation-manifest-descriptor.gmdo": "generic manifest descriptor opt",
"annotation-manifest[linux/amd64].mo": "amd64 manifest opt",
"annotation-manifest-descriptor[linux/amd64].mdo": "amd64 manifest descriptor opt",
"annotation-manifest[linux/arm64/v8].mo": "arm64 manifest opt",
"annotation-manifest-descriptor[linux/arm64/v8].mdo": "arm64 manifest descriptor opt",
},
},
},
@@ -498,8 +498,8 @@ func testExportAnnotations(t *testing.T, sb integration.Sandbox) {
"annotation-manifest-descriptor.gmdo": "generic manifest descriptor opt",
"annotation-manifest[linux/amd64].mo": "amd64 manifest opt",
"annotation-manifest-descriptor[linux/amd64].mdo": "amd64 manifest descriptor opt",
"annotation-manifest[linux/arm64].mo": "arm64 manifest opt",
"annotation-manifest-descriptor[linux/arm64].mdo": "arm64 manifest descriptor opt",
"annotation-manifest[linux/arm64/v8].mo": "arm64 manifest opt",
"annotation-manifest-descriptor[linux/arm64/v8].mdo": "arm64 manifest descriptor opt",
},
},
},
@@ -103,6 +103,7 @@ func ParseAnnotationKey(result string) (AnnotationKey, bool, error) {
if err != nil {
return AnnotationKey{}, true, err
}
p = platforms.Normalize(p)
ociPlatform = &p
}
@@ -0,0 +1,32 @@
package exptypes
import (
"testing"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/require"
)
func TestParseAnnotationKeyPlatform(t *testing.T) {
for _, tc := range []struct {
platform string
want ocispecs.Platform
}{
{"linux/arm64", ocispecs.Platform{OS: "linux", Architecture: "arm64"}},
{"linux/arm64/v8", ocispecs.Platform{OS: "linux", Architecture: "arm64"}},
{"linux/arm64/8", ocispecs.Platform{OS: "linux", Architecture: "arm64"}},
{"linux/arm64/v9", ocispecs.Platform{OS: "linux", Architecture: "arm64", Variant: "v9"}},
{"linux/arm", ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"}},
{"linux/arm/v6", ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v6"}},
{"linux/arm/v7", ocispecs.Platform{OS: "linux", Architecture: "arm", Variant: "v7"}},
} {
for _, typ := range []string{AnnotationManifest, AnnotationManifestDescriptor} {
t.Run(typ+"/"+tc.platform, func(t *testing.T) {
key, ok, err := ParseAnnotationKey("annotation-" + typ + "[" + tc.platform + "].example")
require.NoError(t, err)
require.True(t, ok)
require.Equal(t, AnnotationKey{Type: typ, Platform: &tc.want, Key: "example"}, key)
})
}
}
}