This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit c4da7499dd5144cfe4eb89c448c66a84f9c51587 Author: Antonin Stefanutti <anto...@stefanutti.fr> AuthorDate: Tue Jun 1 10:25:46 2021 +0200 chore(api): Encapsulate Maven properties --- config/crd/bases/camel.apache.org_builds.yaml | 13 ++++++----- .../camel.apache.org_integrationplatforms.yaml | 26 +++++++++++++--------- .../1.5.0-snapshot/camel.apache.org_builds.yaml | 13 ++++++----- .../camel.apache.org_integrationplatforms.yaml | 26 +++++++++++++--------- helm/camel-k/crds/crd-build.yaml | 13 ++++++----- helm/camel-k/crds/crd-integration-platform.yaml | 26 +++++++++++++--------- pkg/apis/camel/v1/build_types.go | 1 - pkg/apis/camel/v1/common_types.go | 9 ++++++-- pkg/apis/camel/v1/integrationplatform_types.go | 1 - pkg/apis/camel/v1/zz_generated.deepcopy.go | 21 ++++++----------- pkg/builder/quarkus.go | 2 +- pkg/cmd/install.go | 15 ++++++------- pkg/cmd/install_test.go | 8 +++---- pkg/trait/builder.go | 17 +++++++------- pkg/trait/builder_test.go | 4 ++-- 15 files changed, 108 insertions(+), 87 deletions(-) diff --git a/config/crd/bases/camel.apache.org_builds.yaml b/config/crd/bases/camel.apache.org_builds.yaml index 93abf75..09b377e 100644 --- a/config/crd/bases/camel.apache.org_builds.yaml +++ b/config/crd/bases/camel.apache.org_builds.yaml @@ -155,9 +155,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret + key that contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -206,10 +213,6 @@ spec: type: object name: type: string - properties: - additionalProperties: - type: string - type: object resources: items: description: ResourceSpec -- diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml index d2ffaa1..9282305 100644 --- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml +++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml @@ -106,9 +106,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret key that + contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -155,10 +162,6 @@ spec: type: object persistentVolumeClaim: type: string - properties: - additionalProperties: - type: string - type: object publishStrategy: description: IntegrationPlatformBuildPublishStrategy enumerates all implemented publish strategies @@ -280,9 +283,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret key that + contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -329,10 +339,6 @@ spec: type: object persistentVolumeClaim: type: string - properties: - additionalProperties: - type: string - type: object publishStrategy: description: IntegrationPlatformBuildPublishStrategy enumerates all implemented publish strategies diff --git a/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_builds.yaml b/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_builds.yaml index 93abf75..09b377e 100644 --- a/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_builds.yaml +++ b/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_builds.yaml @@ -155,9 +155,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret + key that contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -206,10 +213,6 @@ spec: type: object name: type: string - properties: - additionalProperties: - type: string - type: object resources: items: description: ResourceSpec -- diff --git a/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_integrationplatforms.yaml b/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_integrationplatforms.yaml index d2ffaa1..9282305 100644 --- a/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_integrationplatforms.yaml +++ b/deploy/olm-catalog/camel-k-dev/1.5.0-snapshot/camel.apache.org_integrationplatforms.yaml @@ -106,9 +106,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret key that + contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -155,10 +162,6 @@ spec: type: object persistentVolumeClaim: type: string - properties: - additionalProperties: - type: string - type: object publishStrategy: description: IntegrationPlatformBuildPublishStrategy enumerates all implemented publish strategies @@ -280,9 +283,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret key that + contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -329,10 +339,6 @@ spec: type: object persistentVolumeClaim: type: string - properties: - additionalProperties: - type: string - type: object publishStrategy: description: IntegrationPlatformBuildPublishStrategy enumerates all implemented publish strategies diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml index 93abf75..09b377e 100644 --- a/helm/camel-k/crds/crd-build.yaml +++ b/helm/camel-k/crds/crd-build.yaml @@ -155,9 +155,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret + key that contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -206,10 +213,6 @@ spec: type: object name: type: string - properties: - additionalProperties: - type: string - type: object resources: items: description: ResourceSpec -- diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml index d2ffaa1..9282305 100644 --- a/helm/camel-k/crds/crd-integration-platform.yaml +++ b/helm/camel-k/crds/crd-integration-platform.yaml @@ -106,9 +106,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret key that + contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -155,10 +162,6 @@ spec: type: object persistentVolumeClaim: type: string - properties: - additionalProperties: - type: string - type: object publishStrategy: description: IntegrationPlatformBuildPublishStrategy enumerates all implemented publish strategies @@ -280,9 +283,16 @@ spec: - key type: object localRepository: + description: The path of the local Maven repository. type: string + properties: + additionalProperties: + type: string + description: The Maven properties. + type: object settings: - description: ValueSource -- + description: A reference to the ConfigMap or Secret key that + contains the Maven settings. properties: configMapKeyRef: description: Selects a key of a ConfigMap. @@ -329,10 +339,6 @@ spec: type: object persistentVolumeClaim: type: string - properties: - additionalProperties: - type: string - type: object publishStrategy: description: IntegrationPlatformBuildPublishStrategy enumerates all implemented publish strategies diff --git a/pkg/apis/camel/v1/build_types.go b/pkg/apis/camel/v1/build_types.go index 1f480dd..36d72e9 100644 --- a/pkg/apis/camel/v1/build_types.go +++ b/pkg/apis/camel/v1/build_types.go @@ -61,7 +61,6 @@ type BuilderTask struct { Steps []string `json:"steps,omitempty"` Maven MavenSpec `json:"maven,omitempty"` BuildDir string `json:"buildDir,omitempty"` - Properties map[string]string `json:"properties,omitempty"` } // PublishTask -- diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go index 7b7e4a0..ac83542 100644 --- a/pkg/apis/camel/v1/common_types.go +++ b/pkg/apis/camel/v1/common_types.go @@ -88,8 +88,13 @@ type PlatformInjectable interface { // MavenSpec -- type MavenSpec struct { - LocalRepository string `json:"localRepository,omitempty"` - Settings ValueSource `json:"settings,omitempty"` + // The path of the local Maven repository. + LocalRepository string `json:"localRepository,omitempty"` + // The Maven properties. + Properties map[string]string `json:"properties,omitempty"` + // A reference to the ConfigMap or Secret key that contains + // the Maven settings. + Settings ValueSource `json:"settings,omitempty"` // The Secret name and key, containing the CA certificate(s) used to connect // to remote Maven repositories. // It can contain X.509 certificates, and PKCS#7 formatted certificate chains. diff --git a/pkg/apis/camel/v1/integrationplatform_types.go b/pkg/apis/camel/v1/integrationplatform_types.go index b106a5b..a2cc133 100644 --- a/pkg/apis/camel/v1/integrationplatform_types.go +++ b/pkg/apis/camel/v1/integrationplatform_types.go @@ -111,7 +111,6 @@ type IntegrationPlatformBuildSpec struct { RuntimeVersion string `json:"runtimeVersion,omitempty"` RuntimeProvider RuntimeProvider `json:"runtimeProvider,omitempty"` BaseImage string `json:"baseImage,omitempty"` - Properties map[string]string `json:"properties,omitempty"` Registry IntegrationPlatformRegistrySpec `json:"registry,omitempty"` Timeout *metav1.Duration `json:"timeout,omitempty"` PersistentVolumeClaim string `json:"persistentVolumeClaim,omitempty"` diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go index 86bebcd..270d0fe 100644 --- a/pkg/apis/camel/v1/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go @@ -227,13 +227,6 @@ func (in *BuilderTask) DeepCopyInto(out *BuilderTask) { copy(*out, *in) } in.Maven.DeepCopyInto(&out.Maven) - if in.Properties != nil { - in, out := &in.Properties, &out.Properties - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuilderTask. @@ -866,13 +859,6 @@ 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 - if in.Properties != nil { - in, out := &in.Properties, &out.Properties - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } out.Registry = in.Registry if in.Timeout != nil { in, out := &in.Timeout, &out.Timeout @@ -1268,6 +1254,13 @@ func (in *MavenArtifact) DeepCopy() *MavenArtifact { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MavenSpec) DeepCopyInto(out *MavenSpec) { *out = *in + if in.Properties != nil { + in, out := &in.Properties, &out.Properties + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.Settings.DeepCopyInto(&out.Settings) if in.CASecret != nil { in, out := &in.CASecret, &out.CASecret diff --git a/pkg/builder/quarkus.go b/pkg/builder/quarkus.go index 6eae256..4678be5 100644 --- a/pkg/builder/quarkus.go +++ b/pkg/builder/quarkus.go @@ -79,7 +79,7 @@ func generateQuarkusProject(ctx *builderContext) error { p := GenerateQuarkusProjectCommon(ctx.Build.Runtime.Metadata["camel-quarkus.version"], ctx.Build.Runtime.Version, ctx.Build.Runtime.Metadata["quarkus.version"]) // Add all the properties from the build configuration - p.Properties.AddAll(ctx.Build.Properties) + p.Properties.AddAll(ctx.Build.Maven.Properties) ctx.Maven.Project = p diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 9ae96d4..676aa9c 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -113,8 +113,9 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO cmd.Flags().String("olm-global-namespace", olm.DefaultGlobalNamespace, "A namespace containing an OperatorGroup that defines global scope for the "+ "operator (used in combination with the --global flag)") - // Maven settings + // Maven cmd.Flags().String("local-repository", "", "Location of the local Maven repository") + cmd.Flags().StringArray("maven-property", nil, "Add a Maven property") cmd.Flags().String("maven-settings", "", "Configure the source of the Maven settings (configmap|secret:name[/key])") cmd.Flags().StringArray("maven-repository", nil, "Add a Maven repository") cmd.Flags().String("maven-ca-secret", "", "Configure the secret key containing the Maven CA certificates (secret/key)") @@ -168,13 +169,13 @@ type installCmdOptions struct { BuildStrategy string `mapstructure:"build-strategy"` BuildPublishStrategy string `mapstructure:"build-publish-strategy"` BuildTimeout string `mapstructure:"build-timeout"` + MavenProperties []string `mapstructure:"maven-properties"` MavenRepositories []string `mapstructure:"maven-repositories"` MavenSettings string `mapstructure:"maven-settings"` MavenCASecret string `mapstructure:"maven-ca-secret"` HealthPort int32 `mapstructure:"health-port"` Monitoring bool `mapstructure:"monitoring"` MonitoringPort int32 `mapstructure:"monitoring-port"` - Properties []string `mapstructure:"properties"` TraitProfile string `mapstructure:"trait-profile"` Tolerations []string `mapstructure:"tolerations"` NodeSelectors []string `mapstructure:"node-selectors"` @@ -313,14 +314,12 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error { platform.Spec.Build.Registry.Secret = generatedSecretName } - if len(o.Properties) > 0 { - platform.Spec.Build.Properties = make(map[string]string) - - for _, property := range o.Properties { + if len(o.MavenProperties) > 0 { + platform.Spec.Build.Maven.Properties = make(map[string]string) + for _, property := range o.MavenProperties { kv := strings.Split(property, "=") - if len(kv) == 2 { - platform.Spec.Build.Properties[kv[0]] = kv[1] + platform.Spec.Build.Maven.Properties[kv[0]] = kv[1] } } } diff --git a/pkg/cmd/install_test.go b/pkg/cmd/install_test.go index b26c3eb..3918931 100644 --- a/pkg/cmd/install_test.go +++ b/pkg/cmd/install_test.go @@ -254,11 +254,11 @@ func TestInstallOutputFlag(t *testing.T) { func TestInstallPropertyFlag(t *testing.T) { installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t) _, err := test.ExecuteCommand(rootCmd, cmdInstall, - "--property", "someString1", - "--property", "someString2") + "--maven-property", "someString1", + "--maven-property", "someString2") assert.Nil(t, err) - assert.Equal(t, "someString1", installCmdOptions.Properties[0]) - assert.Equal(t, "someString2", installCmdOptions.Properties[1]) + assert.Equal(t, "someString1", installCmdOptions.MavenProperties[0]) + assert.Equal(t, "someString2", installCmdOptions.MavenProperties[1]) } func TestInstallRegistryFlag(t *testing.T) { diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go index 69703fe..29821e2 100644 --- a/pkg/trait/builder.go +++ b/pkg/trait/builder.go @@ -22,10 +22,11 @@ import ( "sort" "strings" - v1 "github.com/apache/camel-k/pkg/apis/camel/v1" - "github.com/apache/camel-k/pkg/builder" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v1 "github.com/apache/camel-k/pkg/apis/camel/v1" + "github.com/apache/camel-k/pkg/builder" ) // The builder trait is internally used to determine the best strategy to @@ -141,23 +142,21 @@ func (t *builderTrait) builderTask(e *Environment) (*v1.BuilderTask, error) { }, Runtime: e.CamelCatalog.Runtime, Dependencies: e.IntegrationKit.Spec.Dependencies, - Properties: e.Platform.Status.Build.Properties, Maven: e.Platform.Status.Build.Maven, } - // initialize properties if nil - if task.Properties == nil { - task.Properties = make(map[string]string) + if task.Maven.Properties == nil { + task.Maven.Properties = make(map[string]string) } - // User provided build time configuration properties + // User provided Maven properties if t.Properties != nil { for _, v := range t.Properties { split := strings.Split(v, "=") if len(split) != 2 { - return nil, fmt.Errorf("Build time configuration property must have key=value format, it was %v", v) + return nil, fmt.Errorf("maven property must have key=value format, it was %v", v) } - task.Properties[split[0]] = split[1] + task.Maven.Properties[split[0]] = split[1] } } diff --git a/pkg/trait/builder_test.go b/pkg/trait/builder_test.go index 31fea52..1c5282b 100644 --- a/pkg/trait/builder_test.go +++ b/pkg/trait/builder_test.go @@ -152,7 +152,7 @@ func NewBuilderTestCatalog() *Catalog { return NewCatalog(context.TODO(), nil) } -func TestBuildtimeConfigurationBuilderTrait(t *testing.T) { +func TestMavenPropertyBuilderTrait(t *testing.T) { env := createBuilderTestEnv(v1.IntegrationPlatformClusterKubernetes, v1.IntegrationPlatformBuildPublishStrategyKaniko) builderTrait := createNominalBuilderTraitTest() builderTrait.Properties = append(builderTrait.Properties, "build-time-prop1=build-time-value1") @@ -160,7 +160,7 @@ func TestBuildtimeConfigurationBuilderTrait(t *testing.T) { err := builderTrait.Apply(env) assert.Nil(t, err) - assert.Equal(t, "build-time-value1", env.BuildTasks[0].Builder.Properties["build-time-prop1"]) + assert.Equal(t, "build-time-value1", env.BuildTasks[0].Builder.Maven.Properties["build-time-prop1"]) } func createNominalBuilderTraitTest() *builderTrait {