Skip to content

Commit 5fa4de4

Browse files
committed
executor: resolve BultInArgs while expanding baseImage
While creating a dependency map, executor must consider expanding base images with `builtInArgs` like `TARGETARCH, TARGETOS` etc so buildah can still keep and use the stages as dependency later on. Closes: #4820 Signed-off-by: Aditya R <[email protected]>
1 parent 013a061 commit 5fa4de4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

imagebuildah/executor.go

+2
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,11 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
751751
}
752752
headingArgs := argsMapToSlice(stage.Builder.HeadingArgs)
753753
userArgs := argsMapToSlice(stage.Builder.Args)
754+
populatedBuiltInBuildArgs := argsMapToSlice(imagebuilder.BuiltInBuildArgs)
754755
// append heading args so if --build-arg key=value is not
755756
// specified but default value is set in Containerfile
756757
// via `ARG key=value` so default value can be used.
758+
userArgs = append(userArgs, populatedBuiltInBuildArgs...)
757759
userArgs = append(headingArgs, userArgs...)
758760
baseWithArg, err := imagebuilder.ProcessWord(base, userArgs)
759761
if err != nil {

tests/bud.bats

+4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ symlink(subdir)"
266266

267267
run_buildah build --platform linux/$myarch/$myvariant $WITH_POLICY_JSON -t test -f $BUDFILES/base-with-arg/Containerfile
268268
expect_output --substring "This is built for $myarch"
269+
270+
# Should work without platform string as well
271+
run_buildah build $WITH_POLICY_JSON -t test -f $BUDFILES/base-with-arg/Containerfile
272+
expect_output --substring "This is built for $myarch"
269273
}
270274

271275
@test "build with basename resolving user arg" {

0 commit comments

Comments
 (0)