Skip to content

stage_executor,getCreatedBy: expand buildArgs before invoking generatePathChecksum #6110

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

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions imagebuildah/stage_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,10 @@ func (s *StageExecutor) getCreatedBy(node *parser.Node, addedContentSummary stri
continue
}
mountOptionSource = mountInfo.Source
mountOptionSource, err = imagebuilder.ProcessWord(mountOptionSource, s.stage.Builder.Arguments())
if err != nil {
return "", fmt.Errorf("getCreatedBy: while replacing arg variables with values for format %q: %w", mountOptionSource, err)
}
mountOptionFrom = mountInfo.From
// If source is not specified then default is '.'
if mountOptionSource == "" {
Expand Down
10 changes: 10 additions & 0 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6757,6 +6757,16 @@ _EOF
expect_output --substring "hello"
}

@test "bud-with-mount-relative-path-like-buildkit-arg-in-source" {
skip_if_no_runtime
skip_if_in_container
_prefetch alpine
local contextdir=${TEST_SCRATCH_DIR}/buildkit-mount
cp -R $BUDFILES/buildkit-mount $contextdir
run_buildah build --build-arg INPUTPATH_1=subdir -t testbud $WITH_POLICY_JSON -f $contextdir/Containerfile5 $contextdir/
expect_output --substring "hello"
}

@test "bud-with-mount-with-rw-like-buildkit" {
skip_if_no_runtime
skip_if_in_container
Expand Down
5 changes: 5 additions & 0 deletions tests/bud/buildkit-mount/Containerfile5
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine
ARG INPUTPATH_1=subdir
RUN mkdir /test
# use option z if selinux is enabled
RUN --mount=type=bind,source=${INPUTPATH_1:?}/,target=/test,z cat /test/input_file