Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exporter/containerimage/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (ag AnnotationsGroup) Platform(p *ocispecs.Platform) *Annotations {

ps := []string{""}
if p != nil {
ps = append(ps, platforms.FormatAll(*p))
ps = append(ps, platforms.FormatAll(platforms.Normalize(*p)))
}

for _, a := range ag {
Expand Down
33 changes: 33 additions & 0 deletions exporter/containerimage/annotations_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package containerimage

import (
"testing"

"github.com/moby/buildkit/exporter/containerimage/exptypes"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/require"
)

func TestAnnotationsPlatformNormalized(t *testing.T) {
ag, rest, err := ParseAnnotations(map[string][]byte{
"annotation-manifest-descriptor[linux/arm64/v8].example": []byte("v"),
})
require.NoError(t, err)
require.Empty(t, rest)

for _, p := range []ocispecs.Platform{
{OS: "linux", Architecture: "arm64"},
{OS: "linux", Architecture: "arm64", Variant: "v8"},
} {
a := ag.Platform(&p)
require.Equal(t, map[string]string{"example": "v"}, a.ManifestDescriptor, p)
}

a := ag.Platform(&ocispecs.Platform{OS: "linux", Architecture: "amd64"})
require.Empty(t, a.ManifestDescriptor)

k, ok, err := exptypes.ParseAnnotationKey("annotation-manifest[linux/arm64/v8].k")
require.NoError(t, err)
require.True(t, ok)
require.Equal(t, "linux/arm64", k.PlatformString())
}
1 change: 1 addition & 0 deletions exporter/containerimage/exptypes/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func ParseAnnotationKey(result string) (AnnotationKey, bool, error) {
if err != nil {
return AnnotationKey{}, true, err
}
p = platforms.Normalize(p)
ociPlatform = &p
}

Expand Down
Loading