From 9746d6e01007e51c41b40d93287a996c5a3b8169 Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Thu, 1 Feb 2024 18:05:16 +0100 Subject: [PATCH] fix(trait): deprecate operator inspecting secrets Eventually remove this feature which is making the operator to inspect the list of namespaces secrets --- .../ROOT/partials/apis/camel-k-crds.adoc | 10 ++++ docs/modules/traits/pages/mount.adoc | 7 +++ .../crds/crd-integration-platform.yaml | 16 ++++++ .../camel-k/crds/crd-integration-profile.yaml | 16 ++++++ helm/camel-k/crds/crd-integration.yaml | 16 ++++++ helm/camel-k/crds/crd-kamelet-binding.yaml | 10 ++++ helm/camel-k/crds/crd-pipe.yaml | 10 ++++ .../camel/v1/integration_types_support.go | 15 ------ pkg/apis/camel/v1/trait/mount.go | 5 ++ .../camel/v1/trait/zz_generated.deepcopy.go | 5 ++ ...camel.apache.org_integrationplatforms.yaml | 16 ++++++ .../camel.apache.org_integrationprofiles.yaml | 16 ++++++ .../bases/camel.apache.org_integrations.yaml | 16 ++++++ .../camel.apache.org_kameletbindings.yaml | 10 ++++ .../crd/bases/camel.apache.org_pipes.yaml | 10 ++++ pkg/trait/kamelets.go | 20 +++----- pkg/trait/kamelets_test.go | 20 +++----- pkg/trait/mount.go | 50 ++++++++++++++++++- pkg/trait/quarkus.go | 3 +- 19 files changed, 228 insertions(+), 43 deletions(-) diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc index b49c762606..fb1fca5914 100644 --- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc +++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc @@ -7706,6 +7706,16 @@ bool Enable "hot reload" when a secret/configmap mounted is edited (default `false`). The configmap/secret must be marked with `camel.apache.org/integration` label to be taken in account. +|`scanKameletsImplicitLabelSecrets` + +bool +| + + +Deprecated: include your properties in an explicit property file backed by a secret. +Let the operator to scan for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. +These secrets are mounted to the application and treated as plain properties file with their key/value list +(ie .spec.data["camel.my-property"] = my-value) (default `true`). + |=== diff --git a/docs/modules/traits/pages/mount.adoc b/docs/modules/traits/pages/mount.adoc index 1077b8e48e..8ae8213799 100644 --- a/docs/modules/traits/pages/mount.adoc +++ b/docs/modules/traits/pages/mount.adoc @@ -50,6 +50,13 @@ Syntax: [configmap\|secret]:name[/key][@path], where name represents the resourc | Enable "hot reload" when a secret/configmap mounted is edited (default `false`). The configmap/secret must be marked with `camel.apache.org/integration` label to be taken in account. +| mount.scan-kamelets-implicit-label-secrets +| bool +| Deprecated: include your properties in an explicit property file backed by a secret. +Let the operator to scan for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. +These secrets are mounted to the application and treated as plain properties file with their key/value list +(ie .spec.data["camel.my-property"] = my-value) (default `true`). + |=== // End of autogenerated code - DO NOT EDIT! (configuration) diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml index 21cb6d2651..ca1c07a64e 100644 --- a/helm/camel-k/crds/crd-integration-platform.yaml +++ b/helm/camel-k/crds/crd-integration-platform.yaml @@ -1490,6 +1490,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' @@ -3364,6 +3372,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/helm/camel-k/crds/crd-integration-profile.yaml b/helm/camel-k/crds/crd-integration-profile.yaml index 3e997b3cea..6f15c47ed8 100644 --- a/helm/camel-k/crds/crd-integration-profile.yaml +++ b/helm/camel-k/crds/crd-integration-profile.yaml @@ -1372,6 +1372,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' @@ -3135,6 +3143,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml index 828d4041eb..2bfcda1f10 100644 --- a/helm/camel-k/crds/crd-integration.yaml +++ b/helm/camel-k/crds/crd-integration.yaml @@ -7391,6 +7391,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' @@ -9112,6 +9120,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml b/helm/camel-k/crds/crd-kamelet-binding.yaml index 2353b10ef9..16ff4217b0 100644 --- a/helm/camel-k/crds/crd-kamelet-binding.yaml +++ b/helm/camel-k/crds/crd-kamelet-binding.yaml @@ -7688,6 +7688,16 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an + explicit property file backed by a secret. Let the operator + to scan for secret labeled with `camel.apache.org/kamelet` + and `camel.apache.org/kamelet.configuration`. These + secrets are mounted to the application and treated as + plain properties file with their key/value list (ie + .spec.data["camel.my-property"] = my-value) (default + `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/helm/camel-k/crds/crd-pipe.yaml b/helm/camel-k/crds/crd-pipe.yaml index 1dbff73684..700b8e1a72 100644 --- a/helm/camel-k/crds/crd-pipe.yaml +++ b/helm/camel-k/crds/crd-pipe.yaml @@ -7686,6 +7686,16 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an + explicit property file backed by a secret. Let the operator + to scan for secret labeled with `camel.apache.org/kamelet` + and `camel.apache.org/kamelet.configuration`. These + secrets are mounted to the application and treated as + plain properties file with their key/value list (ie + .spec.data["camel.my-property"] = my-value) (default + `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/pkg/apis/camel/v1/integration_types_support.go b/pkg/apis/camel/v1/integration_types_support.go index 3342be76a6..e124cb71e4 100644 --- a/pkg/apis/camel/v1/integration_types_support.go +++ b/pkg/apis/camel/v1/integration_types_support.go @@ -155,21 +155,6 @@ func (in *IntegrationStatus) AddOrReplaceGeneratedSources(sources ...SourceSpec) in.GeneratedSources = append(in.GeneratedSources, newSources...) } -func (in *IntegrationStatus) AddConfigurationsIfMissing(configurations ...ConfigurationSpec) { - for _, config := range configurations { - alreadyPresent := false - for _, r := range in.Configuration { - if r.Type == config.Type && r.Value == config.Value { - alreadyPresent = true - break - } - } - if !alreadyPresent { - in.Configuration = append(in.Configuration, config) - } - } -} - func (in *IntegrationSpec) Configurations() []ConfigurationSpec { if in == nil { return []ConfigurationSpec{} diff --git a/pkg/apis/camel/v1/trait/mount.go b/pkg/apis/camel/v1/trait/mount.go index a0bcb889a7..969ac8a520 100644 --- a/pkg/apis/camel/v1/trait/mount.go +++ b/pkg/apis/camel/v1/trait/mount.go @@ -38,4 +38,9 @@ type MountTrait struct { // Enable "hot reload" when a secret/configmap mounted is edited (default `false`). The configmap/secret must be // marked with `camel.apache.org/integration` label to be taken in account. HotReload *bool `property:"hot-reload" json:"hotReload,omitempty"` + // Deprecated: include your properties in an explicit property file backed by a secret. + // Let the operator to scan for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + // These secrets are mounted to the application and treated as plain properties file with their key/value list + // (ie .spec.data["camel.my-property"] = my-value) (default `true`). + ScanKameletsImplicitLabelSecrets *bool `property:"scan-kamelets-implicit-label-secrets" json:"scanKameletsImplicitLabelSecrets,omitempty"` } diff --git a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go index 28edd1939a..abe7018091 100644 --- a/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/trait/zz_generated.deepcopy.go @@ -741,6 +741,11 @@ func (in *MountTrait) DeepCopyInto(out *MountTrait) { *out = new(bool) **out = **in } + if in.ScanKameletsImplicitLabelSecrets != nil { + in, out := &in.ScanKameletsImplicitLabelSecrets, &out.ScanKameletsImplicitLabelSecrets + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MountTrait. diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml index 21cb6d2651..ca1c07a64e 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml @@ -1490,6 +1490,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' @@ -3364,6 +3372,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml index 3e997b3cea..6f15c47ed8 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml @@ -1372,6 +1372,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' @@ -3135,6 +3143,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml index 828d4041eb..2bfcda1f10 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml @@ -7391,6 +7391,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' @@ -9112,6 +9120,14 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an explicit + property file backed by a secret. Let the operator to scan + for secret labeled with `camel.apache.org/kamelet` and `camel.apache.org/kamelet.configuration`. + These secrets are mounted to the application and treated + as plain properties file with their key/value list (ie .spec.data["camel.my-property"] + = my-value) (default `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml b/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml index 2353b10ef9..16ff4217b0 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml @@ -7688,6 +7688,16 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an + explicit property file backed by a secret. Let the operator + to scan for secret labeled with `camel.apache.org/kamelet` + and `camel.apache.org/kamelet.configuration`. These + secrets are mounted to the application and treated as + plain properties file with their key/value list (ie + .spec.data["camel.my-property"] = my-value) (default + `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml b/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml index 1dbff73684..700b8e1a72 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml @@ -7686,6 +7686,16 @@ spec: items: type: string type: array + scanKameletsImplicitLabelSecrets: + description: 'Deprecated: include your properties in an + explicit property file backed by a secret. Let the operator + to scan for secret labeled with `camel.apache.org/kamelet` + and `camel.apache.org/kamelet.configuration`. These + secrets are mounted to the application and treated as + plain properties file with their key/value list (ie + .spec.data["camel.my-property"] = my-value) (default + `true`).' + type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path]' diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go index d0df47924f..607d41a05b 100644 --- a/pkg/trait/kamelets.go +++ b/pkg/trait/kamelets.go @@ -41,6 +41,7 @@ import ( ) const ( + kameletsTraitID = "kamelets" contentKey = "content" KameletLocationProperty = "camel.component.kamelet.location" kameletLabel = "camel.apache.org/kamelet" @@ -107,10 +108,6 @@ func (t *kameletsTrait) Apply(e *Environment) error { return err } } - if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) { - return t.addConfigurationSecrets(e) - } - return nil } @@ -261,7 +258,9 @@ func (t *kameletsTrait) addKameletAsSource(e *Environment, kamelet *v1.Kamelet) return nil } -func (t *kameletsTrait) addConfigurationSecrets(e *Environment) error { +// Deprecated: use explicit secret configuration instead. +func (t *kameletsTrait) listConfigurationSecrets(e *Environment) ([]string, error) { + listConfigurationSecrets := make([]string, 0) for _, k := range t.getConfigurationKeys() { options := metav1.ListOptions{ LabelSelector: fmt.Sprintf("%s=%s", kameletLabel, k.kamelet), @@ -271,21 +270,16 @@ func (t *kameletsTrait) addConfigurationSecrets(e *Environment) error { } secrets, err := t.Client.CoreV1().Secrets(e.Integration.Namespace).List(e.Ctx, options) if err != nil { - return err + return nil, err } - for _, item := range secrets.Items { if item.Labels != nil && item.Labels[kameletConfigurationLabel] != k.configurationID { continue } - - e.Integration.Status.AddConfigurationsIfMissing(v1.ConfigurationSpec{ - Type: "secret", - Value: item.Name, - }) + listConfigurationSecrets = append(listConfigurationSecrets, item.Name) } } - return nil + return listConfigurationSecrets, nil } func (t *kameletsTrait) getKameletKeys() []string { diff --git a/pkg/trait/kamelets_test.go b/pkg/trait/kamelets_test.go index e3cf4fd09a..4588d496c5 100644 --- a/pkg/trait/kamelets_test.go +++ b/pkg/trait/kamelets_test.go @@ -370,12 +370,10 @@ func TestKameletConfigLookup(t *testing.T) { assert.Equal(t, []string{"timer"}, trait.getKameletKeys()) assert.Equal(t, []configurationKey{newConfigurationKey("timer", "")}, trait.getConfigurationKeys()) - err = trait.Apply(environment) - require.NoError(t, err) - assert.Len(t, environment.Integration.Status.Configuration, 2) - assert.Contains(t, environment.Integration.Status.Configuration, v1.ConfigurationSpec{Type: "secret", Value: "my-secret"}) - assert.NotContains(t, environment.Integration.Status.Configuration, v1.ConfigurationSpec{Type: "secret", Value: "my-secret2"}) - assert.Contains(t, environment.Integration.Status.Configuration, v1.ConfigurationSpec{Type: "secret", Value: "my-secret3"}) + list, err := trait.listConfigurationSecrets(environment) + assert.Nil(t, err) + assert.Contains(t, list, "my-secret", "my-secret3") + assert.NotContains(t, list, "my-secret2") } func TestKameletNamedConfigLookup(t *testing.T) { @@ -437,12 +435,10 @@ func TestKameletNamedConfigLookup(t *testing.T) { newConfigurationKey("timer", "id2"), }, trait.getConfigurationKeys()) - err = trait.Apply(environment) - require.NoError(t, err) - assert.Len(t, environment.Integration.Status.Configuration, 2) - assert.Contains(t, environment.Integration.Status.Configuration, v1.ConfigurationSpec{Type: "secret", Value: "my-secret"}) - assert.Contains(t, environment.Integration.Status.Configuration, v1.ConfigurationSpec{Type: "secret", Value: "my-secret2"}) - assert.NotContains(t, environment.Integration.Status.Configuration, v1.ConfigurationSpec{Type: "secret", Value: "my-secret3"}) + list, err := trait.listConfigurationSecrets(environment) + assert.Nil(t, err) + assert.Contains(t, list, "my-secret", "my-secret2") + assert.NotContains(t, list, "my-secret3") } func TestKameletConditionFalse(t *testing.T) { diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go index 5c00185f5a..e48e153535 100644 --- a/pkg/trait/mount.go +++ b/pkg/trait/mount.go @@ -25,9 +25,11 @@ import ( appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" + "k8s.io/utils/pointer" serving "knative.dev/serving/pkg/apis/serving/v1" + v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1" traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait" "github.com/apache/camel-k/v2/pkg/util/kubernetes" utilResource "github.com/apache/camel-k/v2/pkg/util/resource" @@ -52,6 +54,9 @@ func (t *mountTrait) Configure(e *Environment) (bool, *TraitCondition, error) { // Look for secrets which may have been created by service binding trait t.addServiceBindingSecret(e) + // Look for implicit secrets which may be required by kamelets + condition := t.addImplicitKameletsSecrets(e) + // Validate resources and pvcs for _, c := range t.Configs { if !strings.HasPrefix(c, "configmap:") && !strings.HasPrefix(c, "secret:") { @@ -68,7 +73,7 @@ func (t *mountTrait) Configure(e *Environment) (bool, *TraitCondition, error) { return len(e.Integration.AllSources()) > 0 || len(t.Configs) > 0 || len(t.Resources) > 0 || - len(t.Volumes) > 0, nil, nil + len(t.Volumes) > 0, condition, nil } func (t *mountTrait) Apply(e *Environment) error { @@ -176,3 +181,46 @@ func (t *mountTrait) addServiceBindingSecret(e *Environment) { } }) } + +// Deprecated: to be removed in future releases. +// nolint: staticcheck +func (t *mountTrait) addImplicitKameletsSecrets(e *Environment) *TraitCondition { + featureUsed := false + if trait := e.Catalog.GetTrait(kameletsTraitID); trait != nil { + kamelets, ok := trait.(*kameletsTrait) + if !ok { + return NewIntegrationCondition( + v1.IntegrationConditionTraitInfo, + corev1.ConditionTrue, + traitConfigurationReason, + "Unexpected error happened while casting to kamelets trait", + ) + } + if !pointer.BoolDeref(t.ScanKameletsImplicitLabelSecrets, true) { + return nil + } + implicitKameletSecrets, err := kamelets.listConfigurationSecrets(e) + if err != nil { + return NewIntegrationCondition( + v1.IntegrationConditionTraitInfo, + corev1.ConditionTrue, + traitConfigurationReason, + err.Error(), + ) + } + for _, secret := range implicitKameletSecrets { + featureUsed = true + t.Configs = append(t.Configs, "secret:"+secret) + } + } + + if featureUsed { + return NewIntegrationCondition( + v1.IntegrationConditionTraitInfo, + corev1.ConditionTrue, + traitConfigurationReason, + "Implicit Kamelet labelling secrets are deprecated and may be removed in future releases. Make sure to use explicit mount.config secrets instead.", + ) + } + return nil +} diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go index 52ca72399d..1a57db9b90 100644 --- a/pkg/trait/quarkus.go +++ b/pkg/trait/quarkus.go @@ -36,8 +36,7 @@ import ( ) const ( - quarkusTraitID = "quarkus" - + quarkusTraitID = "quarkus" QuarkusNativeDefaultBaseImageName = "quay.io/quarkus/quarkus-micro-image:2.0" )