From 99a3a184fce465b4c38c13dc6ed50342ac0c7cd0 Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Thu, 18 Apr 2024 16:40:30 +0200 Subject: [PATCH] fix(trait): inherit platform configuration Closes #5289 --- pkg/trait/builder.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index 2bd7b88ec5..115ea6d66d 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -96,6 +96,8 @@ func (t *builderTrait) Configure(e *Environment) (bool, *TraitCondition, error) condition = newOrAppend(condition, "Spectrum publishing strategy is deprecated and may be removed in future releases. Make sure to use any supported publishing strategy instead.") } + t.setPlatform(e) + if e.IntegrationKitInPhase(v1.IntegrationKitPhaseBuildSubmitted) { if trait := e.Catalog.GetTrait(quarkusTraitID); trait != nil { quarkus, ok := trait.(*quarkusTrait) @@ -630,3 +632,12 @@ func publishingOrUserTask(t v1.Task) bool { return false } + +// Will set a default platform if either specified in the trait or the platform/profile configuration. +func (t *builderTrait) setPlatform(e *Environment) { + if t.ImagePlatforms == nil { + if e.Platform != nil && e.Platform.Status.Build.BuildConfiguration.ImagePlatforms != nil { + t.ImagePlatforms = e.Platform.Status.Build.BuildConfiguration.ImagePlatforms + } + } +}