Skip to content

Commit d85425d

Browse files
committed
Only auto-detect platform variant if we are also auto-detecting the architecture
Otherwise, on ARM, users with ArchitectureChoice: "amd64" still end up with a wantedVariant: "v7". Signed-off-by: Miloslav Trmač <mitr@redhat.com>
1 parent 484fa7c commit d85425d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/pkg/platform/platform_matcher.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,17 @@ var compatibility = map[string][]string{
125125
// If some option (arch, os, variant) is not present, a value from current platform is detected.
126126
func WantedPlatforms(ctx *types.SystemContext) ([]imgspecv1.Platform, error) {
127127
wantedArch := runtime.GOARCH
128+
wantedVariant := ""
128129
if ctx != nil && ctx.ArchitectureChoice != "" {
129130
wantedArch = ctx.ArchitectureChoice
131+
} else {
132+
// Only auto-detect the variant if we are using the default architecture.
133+
// If the user has specified the ArchitectureChoice, don't autodetect, even if
134+
// ctx.ArchitectureChoice == runtime.GOARCH, because we have no idea whether the runtime.GOARCH
135+
// value is relevant to the use case, and if we do autodetect a variant,
136+
// ctx.VariantChoice can't be used to override it back to "".
137+
wantedVariant = getCPUVariant(runtime.GOOS, runtime.GOARCH)
130138
}
131-
wantedVariant := getCPUVariant(runtime.GOOS, runtime.GOARCH)
132139
if ctx != nil && ctx.VariantChoice != "" {
133140
wantedVariant = ctx.VariantChoice
134141
}

0 commit comments

Comments
 (0)