diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml index c076777c8c..7c1b33164f 100644 --- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml +++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml @@ -84,13 +84,31 @@ spec: description: the timeout (in seconds) to use when creating the build tools container image type: string - buildStrategy: - description: the strategy to adopt for building an Integration - base image - enum: - - routine - - pod - type: string + buildconfiguration: + description: the configuration required to build an Integration + container image + properties: + limitCPU: + description: The maximum amount of CPU required. + type: string + limitMemory: + description: The maximum amount of memory required. + type: string + requestCPU: + description: The minimum amount of CPU required. + type: string + requestMemory: + description: The minimum amount of memory required. + type: string + strategy: + description: the strategy to adopt + enum: + - routine + - pod + type: string + required: + - strategy + type: object maven: description: Maven configuration used to build the Camel/Camel-Quarkus applications @@ -249,7 +267,7 @@ spec: type: integer publishStrategy: description: the strategy to adopt for publishing an Integration - base image + container image type: string registry: description: the image registry used to push/pull Integration @@ -1671,13 +1689,31 @@ spec: description: the timeout (in seconds) to use when creating the build tools container image type: string - buildStrategy: - description: the strategy to adopt for building an Integration - base image - enum: - - routine - - pod - type: string + buildconfiguration: + description: the configuration required to build an Integration + container image + properties: + limitCPU: + description: The maximum amount of CPU required. + type: string + limitMemory: + description: The maximum amount of memory required. + type: string + requestCPU: + description: The minimum amount of CPU required. + type: string + requestMemory: + description: The minimum amount of memory required. + type: string + strategy: + description: the strategy to adopt + enum: + - routine + - pod + type: string + required: + - strategy + type: object maven: description: Maven configuration used to build the Camel/Camel-Quarkus applications @@ -1836,7 +1872,7 @@ spec: type: integer publishStrategy: description: the strategy to adopt for publishing an Integration - base image + container image type: string registry: description: the image registry used to push/pull Integration diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc index 4cbcfd037e..bb80074cff 100644 --- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc +++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc @@ -495,6 +495,58 @@ A human-readable message indicating details about the transition. BuildConditionType -- +[#_camel_apache_org_v1_BuildConfiguration] +=== BuildConfiguration + +*Appears on:* + +* <<#_camel_apache_org_v1_IntegrationPlatformBuildSpec, IntegrationPlatformBuildSpec>> + +BuildConfiguration represent the configuration required to build the runtime + +[cols="2,2a",options="header"] +|=== +|Field +|Description + +|`strategy` + +*xref:#_camel_apache_org_v1_BuildStrategy[BuildStrategy]* +| + + +the strategy to adopt + +|`requestCPU` + +string +| + + +The minimum amount of CPU required. + +|`requestMemory` + +string +| + + +The minimum amount of memory required. + +|`limitCPU` + +string +| + + +The maximum amount of CPU required. + +|`limitMemory` + +string +| + + +The maximum amount of memory required. + + +|=== + [#_camel_apache_org_v1_BuildPhase] === BuildPhase(`string` alias) @@ -668,11 +720,12 @@ https://github.com/OAI/OpenAPI-Specification/issues/845 *Appears on:* +* <<#_camel_apache_org_v1_BuildConfiguration, BuildConfiguration>> * <<#_camel_apache_org_v1_BuildSpec, BuildSpec>> -* <<#_camel_apache_org_v1_IntegrationPlatformBuildSpec, IntegrationPlatformBuildSpec>> BuildStrategy specifies how the Build should be executed. -It will trigger a Maven process that will take care of producing the expected Camel/Camel-Quarkus runtime. +It will trigger a Maven process (either as an Operator routine or Kubernetes Pod execution) that +will take care of producing the expected Camel/Camel-Quarkus runtime. [#_camel_apache_org_v1_BuildahTask] @@ -2416,19 +2469,19 @@ You can define the build strategy, the image registry to use and the Maven confi |Field |Description -|`buildStrategy` + -*xref:#_camel_apache_org_v1_BuildStrategy[BuildStrategy]* +|`buildconfiguration` + +*xref:#_camel_apache_org_v1_BuildConfiguration[BuildConfiguration]* | -the strategy to adopt for building an Integration base image +the configuration required to build an Integration container image |`publishStrategy` + *xref:#_camel_apache_org_v1_IntegrationPlatformBuildPublishStrategy[IntegrationPlatformBuildPublishStrategy]* | -the strategy to adopt for publishing an Integration base image +the strategy to adopt for publishing an Integration container image |`runtimeVersion` + string diff --git a/e2e/commonwithcustominstall/local_platform_test.go b/e2e/commonwithcustominstall/local_platform_test.go index 98f99924c8..500b6bd1fd 100644 --- a/e2e/commonwithcustominstall/local_platform_test.go +++ b/e2e/commonwithcustominstall/local_platform_test.go @@ -78,7 +78,7 @@ func TestLocalPlatform(t *testing.T) { local := Platform(ns1)() Expect(local.Status.Build.PublishStrategy).To(Equal(pl.Status.Build.PublishStrategy)) - Expect(local.Status.Build.BuildStrategy).To(Equal(pl.Status.Build.BuildStrategy)) + Expect(local.Status.Build.BuildConfiguration.Strategy).To(Equal(pl.Status.Build.BuildConfiguration.Strategy)) Expect(local.Status.Build.Maven.LocalRepository).To(Equal(pl.Status.Build.Maven.LocalRepository)) Expect(local.Status.Build.Maven.CLIOptions).To(ContainElements(pl.Status.Build.Maven.CLIOptions)) Expect(local.Status.Build.Maven.Extension).To(BeEmpty()) diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml index c076777c8c..7c1b33164f 100644 --- a/helm/camel-k/crds/crd-integration-platform.yaml +++ b/helm/camel-k/crds/crd-integration-platform.yaml @@ -84,13 +84,31 @@ spec: description: the timeout (in seconds) to use when creating the build tools container image type: string - buildStrategy: - description: the strategy to adopt for building an Integration - base image - enum: - - routine - - pod - type: string + buildconfiguration: + description: the configuration required to build an Integration + container image + properties: + limitCPU: + description: The maximum amount of CPU required. + type: string + limitMemory: + description: The maximum amount of memory required. + type: string + requestCPU: + description: The minimum amount of CPU required. + type: string + requestMemory: + description: The minimum amount of memory required. + type: string + strategy: + description: the strategy to adopt + enum: + - routine + - pod + type: string + required: + - strategy + type: object maven: description: Maven configuration used to build the Camel/Camel-Quarkus applications @@ -249,7 +267,7 @@ spec: type: integer publishStrategy: description: the strategy to adopt for publishing an Integration - base image + container image type: string registry: description: the image registry used to push/pull Integration @@ -1671,13 +1689,31 @@ spec: description: the timeout (in seconds) to use when creating the build tools container image type: string - buildStrategy: - description: the strategy to adopt for building an Integration - base image - enum: - - routine - - pod - type: string + buildconfiguration: + description: the configuration required to build an Integration + container image + properties: + limitCPU: + description: The maximum amount of CPU required. + type: string + limitMemory: + description: The maximum amount of memory required. + type: string + requestCPU: + description: The minimum amount of CPU required. + type: string + requestMemory: + description: The minimum amount of memory required. + type: string + strategy: + description: the strategy to adopt + enum: + - routine + - pod + type: string + required: + - strategy + type: object maven: description: Maven configuration used to build the Camel/Camel-Quarkus applications @@ -1836,7 +1872,7 @@ spec: type: integer publishStrategy: description: the strategy to adopt for publishing an Integration - base image + container image type: string registry: description: the image registry used to push/pull Integration diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go index 52978eb474..9c6dbe4438 100644 --- a/pkg/apis/camel/v1/common_types.go +++ b/pkg/apis/camel/v1/common_types.go @@ -35,8 +35,23 @@ const ( PlatformSelectorAnnotation = "camel.apache.org/platform.id" ) +// BuildConfiguration represent the configuration required to build the runtime +type BuildConfiguration struct { + // the strategy to adopt + Strategy BuildStrategy `json:"strategy"` + // The minimum amount of CPU required. + RequestCPU string `property:"request-cpu" json:"requestCPU,omitempty"` + // The minimum amount of memory required. + RequestMemory string `property:"request-memory" json:"requestMemory,omitempty"` + // The maximum amount of CPU required. + LimitCPU string `property:"limit-cpu" json:"limitCPU,omitempty"` + // The maximum amount of memory required. + LimitMemory string `property:"limit-memory" json:"limitMemory,omitempty"` +} + // BuildStrategy specifies how the Build should be executed. -// It will trigger a Maven process that will take care of producing the expected Camel/Camel-Quarkus runtime. +// It will trigger a Maven process (either as an Operator routine or Kubernetes Pod execution) that +// will take care of producing the expected Camel/Camel-Quarkus runtime. // +kubebuilder:validation:Enum=routine;pod type BuildStrategy string diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go index 2219f8c636..a759beff35 100644 --- a/pkg/apis/camel/v1/integrationplatform_types.go +++ b/pkg/apis/camel/v1/integrationplatform_types.go @@ -107,9 +107,9 @@ var AllIntegrationPlatformClusters = []IntegrationPlatformCluster{IntegrationPla // This configuration can be used to tune the behavior of the Integration/IntegrationKit image builds. // You can define the build strategy, the image registry to use and the Maven configuration to adopt. type IntegrationPlatformBuildSpec struct { - // the strategy to adopt for building an Integration base image - BuildStrategy BuildStrategy `json:"buildStrategy,omitempty"` - // the strategy to adopt for publishing an Integration base image + // the configuration required to build an Integration container image + BuildConfiguration BuildConfiguration `json:"buildconfiguration,omitempty"` + // the strategy to adopt for publishing an Integration container image PublishStrategy IntegrationPlatformBuildPublishStrategy `json:"publishStrategy,omitempty"` // the Camel K Runtime dependency version RuntimeVersion string `json:"runtimeVersion,omitempty"` diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go index d2a72a6923..33112bd86f 100644 --- a/pkg/apis/camel/v1/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go @@ -127,6 +127,21 @@ func (in *BuildCondition) DeepCopy() *BuildCondition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildConfiguration) DeepCopyInto(out *BuildConfiguration) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildConfiguration. +func (in *BuildConfiguration) DeepCopy() *BuildConfiguration { + if in == nil { + return nil + } + out := new(BuildConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BuildList) DeepCopyInto(out *BuildList) { *out = *in @@ -1299,6 +1314,7 @@ func (in *IntegrationPlatform) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IntegrationPlatformBuildSpec) DeepCopyInto(out *IntegrationPlatformBuildSpec) { *out = *in + out.BuildConfiguration = in.BuildConfiguration out.Registry = in.Registry if in.BuildCatalogToolTimeout != nil { in, out := &in.BuildCatalogToolTimeout, &out.BuildCatalogToolTimeout diff --git a/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go b/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go new file mode 100644 index 0000000000..5dbd927a81 --- /dev/null +++ b/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go @@ -0,0 +1,80 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" +) + +// BuildConfigurationApplyConfiguration represents an declarative configuration of the BuildConfiguration type for use +// with apply. +type BuildConfigurationApplyConfiguration struct { + Strategy *v1.BuildStrategy `json:"strategy,omitempty"` + RequestCPU *string `json:"requestCPU,omitempty"` + RequestMemory *string `json:"requestMemory,omitempty"` + LimitCPU *string `json:"limitCPU,omitempty"` + LimitMemory *string `json:"limitMemory,omitempty"` +} + +// BuildConfigurationApplyConfiguration constructs an declarative configuration of the BuildConfiguration type for use with +// apply. +func BuildConfiguration() *BuildConfigurationApplyConfiguration { + return &BuildConfigurationApplyConfiguration{} +} + +// WithStrategy sets the Strategy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Strategy field is set to the value of the last call. +func (b *BuildConfigurationApplyConfiguration) WithStrategy(value v1.BuildStrategy) *BuildConfigurationApplyConfiguration { + b.Strategy = &value + return b +} + +// WithRequestCPU sets the RequestCPU field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RequestCPU field is set to the value of the last call. +func (b *BuildConfigurationApplyConfiguration) WithRequestCPU(value string) *BuildConfigurationApplyConfiguration { + b.RequestCPU = &value + return b +} + +// WithRequestMemory sets the RequestMemory field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RequestMemory field is set to the value of the last call. +func (b *BuildConfigurationApplyConfiguration) WithRequestMemory(value string) *BuildConfigurationApplyConfiguration { + b.RequestMemory = &value + return b +} + +// WithLimitCPU sets the LimitCPU field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LimitCPU field is set to the value of the last call. +func (b *BuildConfigurationApplyConfiguration) WithLimitCPU(value string) *BuildConfigurationApplyConfiguration { + b.LimitCPU = &value + return b +} + +// WithLimitMemory sets the LimitMemory field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LimitMemory field is set to the value of the last call. +func (b *BuildConfigurationApplyConfiguration) WithLimitMemory(value string) *BuildConfigurationApplyConfiguration { + b.LimitMemory = &value + return b +} diff --git a/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go b/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go index 2775d220ae..6a954c69d7 100644 --- a/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go +++ b/pkg/client/camel/applyconfiguration/camel/v1/integrationplatformbuildspec.go @@ -20,24 +20,24 @@ limitations under the License. package v1 import ( - v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" + camelv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // IntegrationPlatformBuildSpecApplyConfiguration represents an declarative configuration of the IntegrationPlatformBuildSpec type for use // with apply. type IntegrationPlatformBuildSpecApplyConfiguration struct { - BuildStrategy *v1.BuildStrategy `json:"buildStrategy,omitempty"` - PublishStrategy *v1.IntegrationPlatformBuildPublishStrategy `json:"publishStrategy,omitempty"` - RuntimeVersion *string `json:"runtimeVersion,omitempty"` - RuntimeProvider *v1.RuntimeProvider `json:"runtimeProvider,omitempty"` - BaseImage *string `json:"baseImage,omitempty"` - Registry *RegistrySpecApplyConfiguration `json:"registry,omitempty"` - BuildCatalogToolTimeout *metav1.Duration `json:"buildCatalogToolTimeout,omitempty"` - Timeout *metav1.Duration `json:"timeout,omitempty"` - Maven *MavenSpecApplyConfiguration `json:"maven,omitempty"` - PublishStrategyOptions map[string]string `json:"PublishStrategyOptions,omitempty"` - MaxRunningBuilds *int32 `json:"maxRunningBuilds,omitempty"` + BuildConfiguration *BuildConfigurationApplyConfiguration `json:"buildconfiguration,omitempty"` + PublishStrategy *camelv1.IntegrationPlatformBuildPublishStrategy `json:"publishStrategy,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + RuntimeProvider *camelv1.RuntimeProvider `json:"runtimeProvider,omitempty"` + BaseImage *string `json:"baseImage,omitempty"` + Registry *RegistrySpecApplyConfiguration `json:"registry,omitempty"` + BuildCatalogToolTimeout *metav1.Duration `json:"buildCatalogToolTimeout,omitempty"` + Timeout *metav1.Duration `json:"timeout,omitempty"` + Maven *MavenSpecApplyConfiguration `json:"maven,omitempty"` + PublishStrategyOptions map[string]string `json:"PublishStrategyOptions,omitempty"` + MaxRunningBuilds *int32 `json:"maxRunningBuilds,omitempty"` } // IntegrationPlatformBuildSpecApplyConfiguration constructs an declarative configuration of the IntegrationPlatformBuildSpec type for use with @@ -46,18 +46,18 @@ func IntegrationPlatformBuildSpec() *IntegrationPlatformBuildSpecApplyConfigurat return &IntegrationPlatformBuildSpecApplyConfiguration{} } -// WithBuildStrategy sets the BuildStrategy field in the declarative configuration to the given value +// WithBuildConfiguration sets the BuildConfiguration field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the BuildStrategy field is set to the value of the last call. -func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithBuildStrategy(value v1.BuildStrategy) *IntegrationPlatformBuildSpecApplyConfiguration { - b.BuildStrategy = &value +// If called multiple times, the BuildConfiguration field is set to the value of the last call. +func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithBuildConfiguration(value *BuildConfigurationApplyConfiguration) *IntegrationPlatformBuildSpecApplyConfiguration { + b.BuildConfiguration = value return b } // WithPublishStrategy sets the PublishStrategy field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the PublishStrategy field is set to the value of the last call. -func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithPublishStrategy(value v1.IntegrationPlatformBuildPublishStrategy) *IntegrationPlatformBuildSpecApplyConfiguration { +func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithPublishStrategy(value camelv1.IntegrationPlatformBuildPublishStrategy) *IntegrationPlatformBuildSpecApplyConfiguration { b.PublishStrategy = &value return b } @@ -73,7 +73,7 @@ func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithRuntimeVersion(valu // WithRuntimeProvider sets the RuntimeProvider field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the RuntimeProvider field is set to the value of the last call. -func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithRuntimeProvider(value v1.RuntimeProvider) *IntegrationPlatformBuildSpecApplyConfiguration { +func (b *IntegrationPlatformBuildSpecApplyConfiguration) WithRuntimeProvider(value camelv1.RuntimeProvider) *IntegrationPlatformBuildSpecApplyConfiguration { b.RuntimeProvider = &value return b } diff --git a/pkg/client/camel/applyconfiguration/utils.go b/pkg/client/camel/applyconfiguration/utils.go index 643e1b8e69..ab9537c952 100644 --- a/pkg/client/camel/applyconfiguration/utils.go +++ b/pkg/client/camel/applyconfiguration/utils.go @@ -44,6 +44,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &camelv1.BuildahTaskApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("BuildCondition"): return &camelv1.BuildConditionApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("BuildConfiguration"): + return &camelv1.BuildConfigurationApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("BuilderTask"): return &camelv1.BuilderTaskApplyConfiguration{} case v1.SchemeGroupVersion.WithKind("BuildSpec"): diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 616f0ec6f7..9d47a20d96 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -526,7 +526,7 @@ func (o *installCmdOptions) setupIntegrationPlatform( platform.Spec.Build.BaseImage = o.BaseImage } if o.BuildStrategy != "" { - platform.Spec.Build.BuildStrategy = v1.BuildStrategy(o.BuildStrategy) + platform.Spec.Build.BuildConfiguration.Strategy = v1.BuildStrategy(o.BuildStrategy) } if o.BuildPublishStrategy != "" { platform.Spec.Build.PublishStrategy = v1.IntegrationPlatformBuildPublishStrategy(o.BuildPublishStrategy) diff --git a/pkg/controller/integrationkit/build.go b/pkg/controller/integrationkit/build.go index c33deb9208..45c7b1a8a4 100644 --- a/pkg/controller/integrationkit/build.go +++ b/pkg/controller/integrationkit/build.go @@ -109,9 +109,9 @@ func (action *buildAction) handleBuildSubmitted(ctx context.Context, kit *v1.Int // It has to be the same namespace as the operator as they must share a PVC builderPodNamespace := platform.GetOperatorNamespace() - buildStrategy := env.Platform.Status.Build.BuildStrategy - if env.BuildStrategy != "" { - buildStrategy = env.BuildStrategy + buildStrategy := env.Platform.Status.Build.BuildConfiguration.Strategy + if env.BuildConfiguration.Strategy != "" { + buildStrategy = env.BuildConfiguration.Strategy } // nolint: contextcheck diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go index 8dbf8a29d5..afc14edb8d 100644 --- a/pkg/platform/defaults.go +++ b/pkg/platform/defaults.go @@ -82,9 +82,9 @@ func ConfigureDefaults(ctx context.Context, c client.Client, p *v1.IntegrationPl log.Debugf("Integration Platform %s [%s]: setting publishing strategy %s", p.Name, p.Namespace, p.Status.Build.PublishStrategy) } - if p.Status.Build.BuildStrategy == "" { - p.Status.Build.BuildStrategy = v1.BuildStrategyPod - log.Debugf("Integration Platform %s [%s]: setting build strategy %s", p.Name, p.Namespace, p.Status.Build.BuildStrategy) + if p.Status.Build.BuildConfiguration.Strategy == "" { + p.Status.Build.BuildConfiguration.Strategy = v1.BuildStrategyPod + log.Debugf("Integration Platform [%s]: setting build strategy %s", p.Namespace, p.Status.Build.BuildConfiguration.Strategy) } err := setPlatformDefaults(p, verbose) @@ -92,7 +92,7 @@ func ConfigureDefaults(ctx context.Context, c client.Client, p *v1.IntegrationPl return err } - if p.Status.Build.BuildStrategy == v1.BuildStrategyPod { + if p.Status.Build.BuildConfiguration.Strategy == v1.BuildStrategyPod { if err := CreateBuilderServiceAccount(ctx, c, p); err != nil { return errors.Wrap(err, "cannot ensure service account is present") } @@ -223,8 +223,8 @@ func applyPlatformSpec(source *v1.IntegrationPlatform, target *v1.IntegrationPla log.Debugf("Integration Platform %s [%s]: setting publish strategy options", target.Name, target.Namespace) target.Status.Build.PublishStrategyOptions = source.Status.Build.PublishStrategyOptions } - if target.Status.Build.BuildStrategy == "" { - target.Status.Build.BuildStrategy = source.Status.Build.BuildStrategy + if target.Status.Build.BuildConfiguration.Strategy == "" { + target.Status.Build.BuildConfiguration.Strategy = source.Status.Build.BuildConfiguration.Strategy } if target.Status.Build.RuntimeVersion == "" { @@ -370,9 +370,9 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error { if p.Status.Build.MaxRunningBuilds <= 0 { log.Debugf("Integration Platform %s [%s]: setting max running builds", p.Name, p.Namespace) - if p.Status.Build.BuildStrategy == v1.BuildStrategyRoutine { + if p.Status.Build.BuildConfiguration.Strategy == v1.BuildStrategyRoutine { p.Status.Build.MaxRunningBuilds = 3 - } else if p.Status.Build.BuildStrategy == v1.BuildStrategyPod { + } else if p.Status.Build.BuildConfiguration.Strategy == v1.BuildStrategyPod { p.Status.Build.MaxRunningBuilds = 10 } } diff --git a/pkg/platform/defaults_test.go b/pkg/platform/defaults_test.go index d5754ba1c5..8b64acea5b 100644 --- a/pkg/platform/defaults_test.go +++ b/pkg/platform/defaults_test.go @@ -38,7 +38,9 @@ func TestApplyGlobalPlatformSpec(t *testing.T) { }, Spec: v1.IntegrationPlatformSpec{ Build: v1.IntegrationPlatformBuildSpec{ - BuildStrategy: v1.BuildStrategyRoutine, + BuildConfiguration: v1.BuildConfiguration{ + Strategy: v1.BuildStrategyRoutine, + }, Maven: v1.MavenSpec{ Properties: map[string]string{ "global_prop1": "global_value1", @@ -79,7 +81,7 @@ func TestApplyGlobalPlatformSpec(t *testing.T) { assert.Equal(t, v1.IntegrationPlatformClusterOpenShift, ip.Status.Cluster) assert.Equal(t, v1.TraitProfileOpenShift, ip.Status.Profile) - assert.Equal(t, v1.BuildStrategyRoutine, ip.Status.Build.BuildStrategy) + assert.Equal(t, v1.BuildStrategyRoutine, ip.Status.Build.BuildConfiguration.Strategy) assert.True(t, ip.Status.Build.MaxRunningBuilds == 3) // default for build strategy routine @@ -106,7 +108,9 @@ func TestRetainLocalPlatformSpec(t *testing.T) { }, Spec: v1.IntegrationPlatformSpec{ Build: v1.IntegrationPlatformBuildSpec{ - BuildStrategy: v1.BuildStrategyRoutine, + BuildConfiguration: v1.BuildConfiguration{ + Strategy: v1.BuildStrategyRoutine, + }, Maven: v1.MavenSpec{ Properties: map[string]string{ "global_prop1": "global_value1", @@ -141,7 +145,9 @@ func TestRetainLocalPlatformSpec(t *testing.T) { }, Spec: v1.IntegrationPlatformSpec{ Build: v1.IntegrationPlatformBuildSpec{ - BuildStrategy: v1.BuildStrategyPod, + BuildConfiguration: v1.BuildConfiguration{ + Strategy: v1.BuildStrategyPod, + }, MaxRunningBuilds: 1, Maven: v1.MavenSpec{ Properties: map[string]string{ @@ -166,7 +172,7 @@ func TestRetainLocalPlatformSpec(t *testing.T) { assert.Equal(t, v1.IntegrationPlatformClusterKubernetes, ip.Status.Cluster) assert.Equal(t, v1.TraitProfileKnative, ip.Status.Profile) - assert.Equal(t, v1.BuildStrategyPod, ip.Status.Build.BuildStrategy) + assert.Equal(t, v1.BuildStrategyPod, ip.Status.Build.BuildConfiguration.Strategy) assert.True(t, ip.Status.Build.MaxRunningBuilds == 1) diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index 629d1fc008..8082e7658c 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -153,9 +153,9 @@ func (t *builderTrait) Apply(e *Environment) error { t.L.Infof("User defined build strategy %s", t.Strategy) switch t.Strategy { case string(v1.BuildStrategyPod): - e.BuildStrategy = v1.BuildStrategyPod + e.BuildConfiguration.Strategy = v1.BuildStrategyPod case string(v1.BuildStrategyRoutine): - e.BuildStrategy = v1.BuildStrategyRoutine + e.BuildConfiguration.Strategy = v1.BuildStrategyRoutine default: return fmt.Errorf("must specify either pod or routine build strategy, unknown %s", t.Strategy) } diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go index a7b6e145a1..f92a272c83 100644 --- a/pkg/trait/quarkus.go +++ b/pkg/trait/quarkus.go @@ -150,7 +150,7 @@ func (t *quarkusTrait) Apply(e *Environment) error { if t.hasKitNativeType() { // Force the build to run in a separate Pod t.L.Info("Quarkus Native requires a build pod strategy") - e.BuildStrategy = v1.BuildStrategyPod + e.BuildConfiguration.Strategy = v1.BuildStrategyPod // TODO we may provide a set of sensible resource default values for the Pod spun off } diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go index bb318270a2..7e8b8654a0 100644 --- a/pkg/trait/trait_types.go +++ b/pkg/trait/trait_types.go @@ -196,8 +196,7 @@ type Environment struct { ApplicationProperties map[string]string Interceptors []string ServiceBindingSecret string - // The strategy to adopt when building a Kit - BuildStrategy v1.BuildStrategy + BuildConfiguration v1.BuildConfiguration } // ControllerStrategy is used to determine the kind of controller that needs to be created for the integration.