Skip to content

Commit

Permalink
imagebuildah.StageExecutor.prepare(): log the --platform flag
Browse files Browse the repository at this point in the history
If FROM was used with a --platform flag, then the imagebuilder.Builder
will have its Platform field set, and we should include it when logging
the instruction.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
  • Loading branch information
nalind committed Jun 20, 2024
1 parent 4c781b5 commit 7db035c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions imagebuildah/stage_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@ func (s *StageExecutor) prepare(ctx context.Context, from string, initializeIBCo
from = base
}
displayFrom := from
if ib.Platform != "" {
displayFrom = "--platform=" + ib.Platform + " " + displayFrom
}

// stage.Name will be a numeric string for all stages without an "AS" clause
asImageName := stage.Name
Expand Down
8 changes: 8 additions & 0 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6838,3 +6838,11 @@ _EOF
run_buildah build $WITH_POLICY_JSON --no-cache --isolation chroot --secret id=MYSECRET -t test -f $contextdir/Dockerfile
expect_output --substring "SOMESECRETDATA"
}

@test "build-logs-from-platform" {
run_buildah info --format '{{.host.os}}/{{.host.arch}}{{if .host.variant}}/{{.host.variant}}{{ end }}'
local platform="$output"
echo FROM --platform=$platform busybox > ${TEST_SCRATCH_DIR}/Containerfile
run_buildah build ${TEST_SCRATCH_DIR}
expect_output --substring "\-\-platform=$platform"
}

0 comments on commit 7db035c

Please sign in to comment.