Skip to content

Commit

Permalink
executor: resolve BultInArgs while expanding baseImage
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
flouthoc committed Jun 2, 2023
1 parent 013a061 commit 5fa4de4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions imagebuildah/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,11 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
}
headingArgs := argsMapToSlice(stage.Builder.HeadingArgs)
userArgs := argsMapToSlice(stage.Builder.Args)
populatedBuiltInBuildArgs := argsMapToSlice(imagebuilder.BuiltInBuildArgs)
// append heading args so if --build-arg key=value is not
// specified but default value is set in Containerfile
// via `ARG key=value` so default value can be used.
userArgs = append(userArgs, populatedBuiltInBuildArgs...)
userArgs = append(headingArgs, userArgs...)
baseWithArg, err := imagebuilder.ProcessWord(base, userArgs)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ symlink(subdir)"

run_buildah build --platform linux/$myarch/$myvariant $WITH_POLICY_JSON -t test -f $BUDFILES/base-with-arg/Containerfile
expect_output --substring "This is built for $myarch"

# Should work without platform string as well
run_buildah build $WITH_POLICY_JSON -t test -f $BUDFILES/base-with-arg/Containerfile
expect_output --substring "This is built for $myarch"
}

@test "build with basename resolving user arg" {
Expand Down

0 comments on commit 5fa4de4

Please sign in to comment.