-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting --arch should set the TARGETARCH build arg #5478
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,26 +243,48 @@ _EOF | |
assert "${checkvars[*]}" != "" \ | ||
"INTERNAL ERROR! No 'ARG xxx' lines in $containerfile!" | ||
|
||
ARCH=$(go env GOARCH) | ||
# With explicit and full --platform, buildah should not warn. | ||
run_buildah build $WITH_POLICY_JSON --platform linux/amd64/v2 \ | ||
-t source -f $containerfile | ||
assert "$output" !~ "missing .* build argument" \ | ||
"With explicit --platform, buildah should not warn" | ||
assert "$output" =~ "image platform \(linux/amd64\) does not match the expected platform" \ | ||
"With explicit --platform, buildah should warn about pulling difference in platform" | ||
assert "$output" =~ "TARGETOS=linux" " --platform TARGETOS set correctly" | ||
assert "$output" =~ "TARGETARCH=amd64" " --platform TARGETARCH set correctly" | ||
assert "$output" =~ "TARGETVARIANT=" " --platform TARGETVARIANT set correctly" | ||
assert "$output" =~ "TARGETPLATFORM=linux/amd64/v2" " --platform TARGETPLATFORM set correctly" | ||
|
||
# Likewise with individual args | ||
run_buildah build $WITH_POLICY_JSON --os linux --arch amd64 --variant v2 \ | ||
-t source -f $containerfile | ||
assert "$output" !~ "missing .* build argument" \ | ||
"With explicit --os + --arch + --variant, buildah should not warn" | ||
|
||
# FIXME FIXME FIXME: #4319: with --os only, buildah should not warn about OS | ||
if false; then | ||
run_buildah build $WITH_POLICY_JSON --os linux \ | ||
-t source -f $containerfile | ||
assert "$output" !~ "missing.*TARGETOS" \ | ||
"With explicit --os (but no arch/variant), buildah should not warn about TARGETOS" | ||
# FIXME: add --arch test too, and maybe make this cleaner | ||
fi | ||
assert "$output" =~ "image platform \(linux/amd64\) does not match the expected platform" \ | ||
"With explicit --variant, buildah should warn about pulling difference in platform" | ||
assert "$output" =~ "TARGETOS=linux" "--os --arch --variant TARGETOS set correctly" | ||
assert "$output" =~ "TARGETARCH=amd64" "--os --arch --variant TARGETARCH set correctly" | ||
assert "$output" =~ "TARGETVARIANT=" "--os --arch --variant TARGETVARIANT set correctly" | ||
assert "$output" =~ "TARGETPLATFORM=linux/amd64" "--os --arch --variant TARGETPLATFORM set correctly" | ||
|
||
run_buildah build $WITH_POLICY_JSON --os linux -t source -f $containerfile | ||
assert "$output" !~ "WARNING" \ | ||
"With explicit --os (but no arch/variant), buildah should not warn about TARGETOS" | ||
assert "$output" =~ "TARGETOS=linux" "--os TARGETOS set correctly" | ||
assert "$output" =~ "TARGETARCH=${ARCH}" "--os TARGETARCH set correctly" | ||
assert "$output" =~ "TARGETVARIANT=" "--os TARGETVARIANT set correctly" | ||
assert "$output" =~ "TARGETPLATFORM=linux/${ARCH}" "--os TARGETPLATFORM set correctly" | ||
|
||
run_buildah build $WITH_POLICY_JSON --arch amd64 -t source -f $containerfile | ||
assert "$output" !~ "WARNING" \ | ||
"With explicit --os (but no arch/variant), buildah should not warn about TARGETOS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error description doesn't seem to match the error message it's checking against. |
||
assert "$output" =~ "TARGETOS=linux" "--arch TARGETOS set correctly" | ||
assert "$output" =~ "TARGETARCH=amd64" "--arch TARGETARCH set correctly" | ||
assert "$output" =~ "TARGETVARIANT=" "--arch TARGETVARIANT set correctly" | ||
assert "$output" =~ "TARGETPLATFORM=linux/amd64" "--arch TARGETPLATFORM set correctly" | ||
|
||
for option in "--arch=arm64" "--os=windows" "--variant=v2"; do | ||
run_buildah 125 build $WITH_POLICY_JSON --platform linux/amd64 ${option} \ | ||
-t source -f $containerfile | ||
assert "$output" =~ "Error: building system context: invalid --platform may not be used with --os, --arch, or --variant" "can't use --platform and one of --os, --arch or --variant together" | ||
done | ||
} | ||
|
||
@test "build-conflicting-isolation-chroot-and-network" { | ||
|
@@ -5729,9 +5751,9 @@ _EOF | |
@test "bud with --pull-always" { | ||
_prefetch docker.io/library/alpine | ||
run_buildah build --pull-always $WITH_POLICY_JSON -t testpull $BUDFILES/containerfile | ||
expect_output --from="${lines[1]}" "Trying to pull docker.io/library/alpine:latest..." | ||
expect_output --substring "Trying to pull docker.io/library/alpine:latest..." | ||
run_buildah build --pull=always $WITH_POLICY_JSON -t testpull $BUDFILES/containerfile | ||
expect_output --from="${lines[1]}" "Trying to pull docker.io/library/alpine:latest..." | ||
expect_output --substring "Trying to pull docker.io/library/alpine:latest..." | ||
} | ||
|
||
@test "bud with --memory and --memory-swap" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is TARGETVARIANT not being set to "v2", per "--platform"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this reveals the fix just not being correct — the core issue is that the
buildDockerfilesOnce
code settingTARGET*
expectsSystemContext.*Choice
to never be""
, and that’s not how the values are set.Compare more in #5543 (review)