Skip to content

build: Use normalized platform spec for ARG expansion#66

Merged
chmeliik merged 2 commits intokonflux-ci:mainfrom
slimreaper35:build-args
Mar 3, 2026
Merged

build: Use normalized platform spec for ARG expansion#66
chmeliik merged 2 commits intokonflux-ci:mainfrom
slimreaper35:build-args

Conversation

@slimreaper35
Copy link
Copy Markdown
Member

No description provided.

@slimreaper35 slimreaper35 requested a review from a team as a code owner February 23, 2026 08:52
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented Feb 23, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

@chmeliik chmeliik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't DefaultSpec() always normalized? I think Normalize() is more for user input.

@slimreaper35
Copy link
Copy Markdown
Member Author

Isn't DefaultSpec() always normalized? I think Normalize() is more for user input.

I didn't find the normalization anywhere.

I encountered this while running integration tests, and the platform variant was part of the TARGETPLATFORM/BUILDPLATFORM string:

Test Failure: image label: BUILDPLATFORM=linux/arm64; containerfile label: BUILDPLATFORM=linux/arm64/v8

So the normalization removes the v8 variant, and the test passes. I believe this condition could be dropped as well (unless there is a different solution).

@chmeliik
Copy link
Copy Markdown
Contributor

chmeliik commented Feb 23, 2026

Isn't DefaultSpec() always normalized? I think Normalize() is more for user input.

I didn't find the normalization anywhere.

I encountered this while running integration tests, and the platform variant was part of the TARGETPLATFORM/BUILDPLATFORM string:

Test Failure: image label: BUILDPLATFORM=linux/arm64; containerfile label: BUILDPLATFORM=linux/arm64/v8

So the normalization removes the v8 variant, and the test passes.

Ah, interesting. In that case yeah, normalization makes sense. Could you also submit a similar patch to https://github.com/konflux-ci/dockerfile-json/ (the dev branch)?

I believe this condition could be dropped as well (unless there is a different solution).

I think the condition will have to be more specific and also expect empty for arm64 v8. Because the variant label should apparently be empty on arm64 v8 but not any other arm variant

@slimreaper35
Copy link
Copy Markdown
Member Author

I think the condition will have to be more specific and also expect empty for arm64 v8.

Only for the arm64?

@chmeliik
Copy link
Copy Markdown
Contributor

I think the condition will have to be more specific and also expect empty for arm64 v8.

Only for the arm64?

If I understand the normalization correctly, then yes. We expect empty VARIANT if:

  • the runtime.GOARCH is not arm*
  • the runtime.GOARCH is arm64 and the variant is v8

The ARG variables for multi-platform builds should use a normalized
platform spec. This ensures consistent formatting across different
platform string representations, particularly for edge cases like
architecture normalization.

--
https://github.com/containers/buildah/blob/c97d402ccd8dbc5442c3b9fd952fece3f22fbce4/internal/util/util.go#L44
https://github.com/containers/common/blob/a5ccdae846b629b5ceaefa6ffd5c6511409c3487/libimage/platform/platform.go#L20

Signed-off-by: Michal Šoltis <msoltis@redhat.com>
After normalization, the variant will be empty in most cases (including
ARM/v8 architecture). We can proceed without conditioned check and just
expect imageLabel to equal to containerfileLabel as for other labels
even if it is an empty string.

Signed-off-by: Michal Šoltis <msoltis@redhat.com>
Copy link
Copy Markdown
Contributor

@chmeliik chmeliik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@chmeliik chmeliik merged commit fa80f20 into konflux-ci:main Mar 3, 2026
7 checks passed
@slimreaper35 slimreaper35 deleted the build-args branch March 3, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants