Skip to content

Commit d15172e

Browse files
committed
stage_executor: reset platform in systemcontext for stages
On processing of every stage platform spec in systemcontext must be correctly reset. [NO NEW TESTS NEEDED] Closes: containers#5968 Signed-off-by: flouthoc <[email protected]>
1 parent 30bf35f commit d15172e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

imagebuildah/stage_executor.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -953,19 +953,18 @@ func (s *StageExecutor) prepare(ctx context.Context, from string, initializeIBCo
953953
}
954954

955955
builderSystemContext := s.executor.systemContext
956-
// get platform string from stage
957-
if stage.Builder.Platform != "" {
958-
os, arch, variant, err := parse.Platform(stage.Builder.Platform)
959-
if err != nil {
960-
return nil, fmt.Errorf("unable to parse platform %q: %w", stage.Builder.Platform, err)
961-
}
962-
if arch != "" || variant != "" {
963-
builderSystemContext.ArchitectureChoice = arch
964-
builderSystemContext.VariantChoice = variant
965-
}
966-
if os != "" {
967-
builderSystemContext.OSChoice = os
968-
}
956+
// stage.Builder.Platform should be empty if user did not set `FROM --platform=<>`
957+
// explicitly for the base image of this image which should set platform to the default.
958+
os, arch, variant, err := parse.Platform(stage.Builder.Platform)
959+
if err != nil {
960+
return nil, fmt.Errorf("unable to parse platform %q: %w", stage.Builder.Platform, err)
961+
}
962+
if arch != "" || variant != "" {
963+
builderSystemContext.ArchitectureChoice = arch
964+
builderSystemContext.VariantChoice = variant
965+
}
966+
if os != "" {
967+
builderSystemContext.OSChoice = os
969968
}
970969

971970
builderOptions := buildah.BuilderOptions{

0 commit comments

Comments
 (0)