diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc index c827f5d9c3..a2ce10971c 100644 --- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc +++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc @@ -7921,10 +7921,7 @@ 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`). +Deprecated: no longer available since version 2.5. |=== diff --git a/docs/modules/traits/pages/mount.adoc b/docs/modules/traits/pages/mount.adoc index 80e3c515b4..64cbadf8ef 100644 --- a/docs/modules/traits/pages/mount.adoc +++ b/docs/modules/traits/pages/mount.adoc @@ -59,10 +59,7 @@ changes in metadata. | 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`). +| Deprecated: no longer available since version 2.5. |=== diff --git a/e2e/common/config/kamelet_config_test.go b/e2e/common/config/kamelet_config_test.go index ad01df563e..930c8089e1 100644 --- a/e2e/common/config/kamelet_config_test.go +++ b/e2e/common/config/kamelet_config_test.go @@ -96,27 +96,6 @@ func TestKameletImplicitConfigDefaultUserProperty(t *testing.T) { g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("My Named Config message")) }) - t.Run("run test named config using labeled secret", func(t *testing.T) { - g.Expect(CreateTimerKamelet(t, ctx, ns, "iconfig06-timer-source")()).To(Succeed()) - - name := RandomizedSuffixName("iconfig-test-timer-source-int6") - secretName := "my-iconfig-int6-secret" - - var secData = make(map[string]string) - secData["camel.kamelet.iconfig06-timer-source.mynamedconfig.message"] = "very top named secret message" - var labels = make(map[string]string) - labels["camel.apache.org/kamelet"] = "iconfig06-timer-source" - labels["camel.apache.org/kamelet.configuration"] = "mynamedconfig" - g.Expect(CreatePlainTextSecretWithLabels(t, ctx, ns, secretName, secData, labels)).To(Succeed()) - g.Eventually(SecretByName(t, ctx, ns, secretName), TestTimeoutLong).Should(Not(BeNil())) - - g.Expect(KamelRun(t, ctx, ns, "files/TimerKameletIntegrationNamedConfiguration06.java", - "-p", "camel.kamelet.iconfig06-timer-source.message='Default message 06'", - "--name", name).Execute()).To(Succeed()) - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("very top named secret message")) - }) - t.Run("run test named config using mounted secret", func(t *testing.T) { g.Expect(CreateTimerKamelet(t, ctx, ns, "iconfig07-timer-source")()).To(Succeed()) @@ -154,25 +133,6 @@ func TestKameletImplicitConfigDefaultUserProperty(t *testing.T) { g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("very top named mounted configmap message")) }) - t.Run("run test default config using labeled secret", func(t *testing.T) { - g.Expect(CreateTimerKamelet(t, ctx, ns, "iconfig09-timer-source")()).To(Succeed()) - - name := RandomizedSuffixName("iconfig-test-timer-source-int9") - secretName := "my-iconfig-int9-secret" - - var secData = make(map[string]string) - secData["camel.kamelet.iconfig09-timer-source.message"] = "very top labeled secret message" - var labels = make(map[string]string) - labels["camel.apache.org/kamelet"] = "iconfig09-timer-source" - g.Expect(CreatePlainTextSecretWithLabels(t, ctx, ns, secretName, secData, labels)).To(Succeed()) - g.Eventually(SecretByName(t, ctx, ns, secretName), TestTimeoutLong).Should(Not(BeNil())) - - g.Expect(KamelRun(t, ctx, ns, "files/TimerKameletIntegrationConfiguration09.java", - "--name", name).Execute()).To(Succeed()) - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("very top labeled secret message")) - }) - t.Run("run test default config inlined properties", func(t *testing.T) { g.Expect(CreateTimerKamelet(t, ctx, ns, "config01-timer-source")()).To(Succeed()) g.Expect(CreateLogKamelet(t, ctx, ns, "config01-log-sink")()).To(Succeed()) diff --git a/e2e/common/config/pipe_config_test.go b/e2e/common/config/pipe_config_test.go index 2ef8c70391..b55a076883 100644 --- a/e2e/common/config/pipe_config_test.go +++ b/e2e/common/config/pipe_config_test.go @@ -54,29 +54,6 @@ func TestPipeConfig(t *testing.T) { g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("myPipeLogger")) }) - t.Run("run test implicit default config using labeled secret", func(t *testing.T) { - name := RandomizedSuffixName("my-pipe-with-default-implicit-secret") - secretName := "my-pipe-default-implicit-secret" - - var secData = make(map[string]string) - secData["camel.kamelet.my-pipe-timer-source.message"] = "My pipe secret message" - var labels = make(map[string]string) - labels["camel.apache.org/kamelet"] = "my-pipe-timer-source" - g.Expect(CreatePlainTextSecretWithLabels(t, ctx, ns, secretName, secData, labels)).To(Succeed()) - - g.Expect(KamelBind(t, ctx, ns, - "my-pipe-timer-source", - "my-pipe-log-sink", - "-p", "sink.loggerName=myDefaultLogger", - "--name", name, - ).Execute()).To(Succeed()) - g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("My pipe secret message")) - g.Eventually(IntegrationLogs(t, ctx, ns, name)).Should(ContainSubstring("myDefaultLogger")) - - g.Expect(DeleteSecret(t, ctx, ns, secretName)).To(Succeed()) - }) - t.Run("run test implicit default config using mounted secret", func(t *testing.T) { name := RandomizedSuffixName("my-pipe-with-default-implicit-secret") secretName := "my-pipe-default-implicit-secret" diff --git a/pkg/apis/camel/v1/trait/mount.go b/pkg/apis/camel/v1/trait/mount.go index f11f18d62e..048b95f30f 100644 --- a/pkg/apis/camel/v1/trait/mount.go +++ b/pkg/apis/camel/v1/trait/mount.go @@ -40,9 +40,6 @@ type MountTrait struct { // marked with `camel.apache.org/integration` label to be taken in account. The resource will be watched for any kind change, also for // changes in metadata. 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`). + // Deprecated: no longer available since version 2.5. ScanKameletsImplicitLabelSecrets *bool `property:"scan-kamelets-implicit-label-secrets" json:"scanKameletsImplicitLabelSecrets,omitempty"` } 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 2eeba0a8c4..5d992edfad 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml @@ -1660,11 +1660,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. @@ -3759,11 +3756,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. 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 6d80e77421..f09ad63fcd 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml @@ -1535,11 +1535,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. @@ -3516,11 +3513,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. 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 a8d5d3c21a..1f8528993a 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml @@ -7551,11 +7551,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be mounted. 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 508d078180..236d804021 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_kameletbindings.yaml @@ -7623,11 +7623,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be 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 25008359fa..85b93bf7e0 100644 --- a/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml +++ b/pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml @@ -7621,11 +7621,8 @@ spec: 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`). + description: 'Deprecated: no longer available since version + 2.5.' type: boolean volumes: description: 'A list of Persistent Volume Claims to be diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go index 402833b9c4..a67570b7de 100644 --- a/pkg/trait/kamelets.go +++ b/pkg/trait/kamelets.go @@ -52,18 +52,6 @@ const ( kameletMountPointAnnotation = "camel.apache.org/kamelet.mount-point" ) -type configurationKey struct { - kamelet string - configurationID string -} - -func newConfigurationKey(kamelet, configurationID string) configurationKey { - return configurationKey{ - kamelet: kamelet, - configurationID: configurationID, - } -} - type kameletsTrait struct { BaseTrait traitv1.KameletsTrait `property:",squash"` @@ -267,30 +255,6 @@ func (t *kameletsTrait) addKameletAsSource(e *Environment, kamelet *v1.Kamelet) return nil } -// 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), - } - if k.configurationID != "" { - options.LabelSelector = fmt.Sprintf("%s=%s,%s=%s", kameletLabel, k.kamelet, kameletConfigurationLabel, k.configurationID) - } - secrets, err := t.Client.CoreV1().Secrets(e.Integration.Namespace).List(e.Ctx, options) - if err != nil { - return nil, err - } - for _, item := range secrets.Items { - if item.Labels != nil && item.Labels[kameletConfigurationLabel] != k.configurationID { - continue - } - listConfigurationSecrets = append(listConfigurationSecrets, item.Name) - } - } - return listConfigurationSecrets, nil -} - func (t *kameletsTrait) getKameletKeys() []string { answer := make([]string, 0) for _, item := range strings.Split(t.List, ",") { @@ -306,36 +270,6 @@ func (t *kameletsTrait) getKameletKeys() []string { return answer } -func (t *kameletsTrait) getConfigurationKeys() []configurationKey { - answer := make([]configurationKey, 0) - for _, item := range t.getKameletKeys() { - answer = append(answer, newConfigurationKey(item, "")) - } - for _, item := range strings.Split(t.List, ",") { - i := strings.Trim(item, " \t\"") - if strings.Contains(i, "/") { - parts := strings.SplitN(i, "/", 2) - newKey := newConfigurationKey(parts[0], parts[1]) - alreadyPresent := false - for _, existing := range answer { - if existing == newKey { - alreadyPresent = true - break - } - } - if !alreadyPresent { - answer = append(answer, newKey) - } - } - } - sort.Slice(answer, func(i, j int) bool { - o1 := answer[i] - o2 := answer[j] - return o1.kamelet < o2.kamelet || (o1.kamelet == o2.kamelet && o1.configurationID < o2.configurationID) - }) - return answer -} - func integrationSourceFromKameletSource(e *Environment, kamelet *v1.Kamelet, source v1.SourceSpec, name string) (v1.SourceSpec, error) { if source.Type == v1.SourceTypeTemplate { // Kamelets must be named ".extension" diff --git a/pkg/trait/kamelets_test.go b/pkg/trait/kamelets_test.go index ff379c74da..afa018df11 100644 --- a/pkg/trait/kamelets_test.go +++ b/pkg/trait/kamelets_test.go @@ -67,16 +67,6 @@ func TestConfigurationWithKamelets(t *testing.T) { assert.True(t, enabled) assert.Nil(t, condition) assert.Equal(t, []string{"c0", "c1", "c2", "complex-.-.-1a", "complex-.-.-1b", "complex-.-.-1c"}, trait.getKameletKeys()) - assert.Equal(t, []configurationKey{ - newConfigurationKey("c0", ""), - newConfigurationKey("c1", ""), - newConfigurationKey("c2", ""), - newConfigurationKey("complex-.-.-1a", ""), - newConfigurationKey("complex-.-.-1b", ""), - newConfigurationKey("complex-.-.-1b", "a"), - newConfigurationKey("complex-.-.-1c", ""), - newConfigurationKey("complex-.-.-1c", "b"), - }, trait.getConfigurationKeys()) } func TestKameletLookup(t *testing.T) { @@ -369,12 +359,6 @@ func TestKameletConfigLookup(t *testing.T) { assert.True(t, enabled) assert.Nil(t, condition) assert.Equal(t, []string{"timer"}, trait.getKameletKeys()) - assert.Equal(t, []configurationKey{newConfigurationKey("timer", "")}, trait.getConfigurationKeys()) - - list, err := trait.listConfigurationSecrets(environment) - require.NoError(t, err) - assert.Contains(t, list, "my-secret", "my-secret3") - assert.NotContains(t, list, "my-secret2") } func TestKameletNamedConfigLookup(t *testing.T) { @@ -431,15 +415,6 @@ func TestKameletNamedConfigLookup(t *testing.T) { assert.True(t, enabled) assert.Nil(t, condition) assert.Equal(t, []string{"timer"}, trait.getKameletKeys()) - assert.Equal(t, []configurationKey{ - newConfigurationKey("timer", ""), - newConfigurationKey("timer", "id2"), - }, trait.getConfigurationKeys()) - - list, err := trait.listConfigurationSecrets(environment) - require.NoError(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/knative_service_test.go b/pkg/trait/knative_service_test.go index 14ecfc461a..24eae32635 100644 --- a/pkg/trait/knative_service_test.go +++ b/pkg/trait/knative_service_test.go @@ -80,17 +80,22 @@ func TestKnativeService(t *testing.T) { Language: v1.LanguageJavaScript, }, }, - Configuration: []v1.ConfigurationSpec{ - {Type: "configmap", Value: "my-cm"}, - {Type: "secret", Value: "my-secret"}, - {Type: "property", Value: "my-property=my-property-value"}, - }, Traits: v1.Traits{ KnativeService: &traitv1.KnativeServiceTrait{ Trait: traitv1.Trait{ Enabled: ptr.To(true), }, }, + Camel: &traitv1.CamelTrait{ + Properties: []string{ + "my-property=my-property-value", + }, + }, + Mount: &traitv1.MountTrait{ + Configs: []string{ + "configmap:my-cm", "secret:my-secret", + }, + }, }, }, }, diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go index becc42da97..5fe56da65d 100644 --- a/pkg/trait/mount.go +++ b/pkg/trait/mount.go @@ -25,11 +25,9 @@ import ( appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" 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/boolean" "github.com/apache/camel-k/v2/pkg/util/kubernetes" @@ -60,9 +58,6 @@ 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:") { @@ -75,7 +70,7 @@ func (t *mountTrait) Configure(e *Environment) (bool, *TraitCondition, error) { } } - return true, condition, nil + return true, nil, nil } func (t *mountTrait) Apply(e *Environment) error { @@ -191,48 +186,3 @@ func (t *mountTrait) addServiceBindingSecret(e *Environment) { } }) } - -// Deprecated: to be removed in future releases. -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( - "Mount", - v1.IntegrationConditionTraitInfo, - corev1.ConditionTrue, - traitConfigurationReason, - "Unexpected error happened while casting to kamelets trait", - ) - } - if !ptr.Deref(t.ScanKameletsImplicitLabelSecrets, true) { - return nil - } - implicitKameletSecrets, err := kamelets.listConfigurationSecrets(e) - if err != nil { - return NewIntegrationCondition( - "Mount", - v1.IntegrationConditionTraitInfo, - corev1.ConditionTrue, - traitConfigurationReason, - err.Error(), - ) - } - for _, secret := range implicitKameletSecrets { - featureUsed = true - t.Configs = append(t.Configs, "secret:"+secret) - } - } - - if featureUsed { - return NewIntegrationCondition( - "Mount", - 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/trait_test.go b/pkg/trait/trait_test.go index a759f17e25..1bbf4d06dd 100644 --- a/pkg/trait/trait_test.go +++ b/pkg/trait/trait_test.go @@ -18,7 +18,6 @@ limitations under the License. package trait import ( - "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -185,79 +184,6 @@ func TestTraitHierarchyDecode(t *testing.T) { assert.Equal(t, 15, *kns.Target) } -func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) { - env := Environment{ - Resources: kubernetes.NewCollection(), - Integration: &v1.Integration{ - ObjectMeta: metav1.ObjectMeta{ - Name: TestDeploymentName, - Namespace: "ns", - }, - Spec: v1.IntegrationSpec{ - Configuration: []v1.ConfigurationSpec{ - { - Type: "property", - Value: "a=b", - }, - { - Type: "configmap", - Value: "test-configmap", - }, - { - Type: "secret", - Value: "test-secret", - }, - { - Type: "volume", - Value: "testvolume:/foo/bar", - }, - { - Type: "volume", - Value: "an-invalid-volume-spec", - }, - }, - }, - }, - } - - vols := make([]corev1.Volume, 0) - mnts := make([]corev1.VolumeMount, 0) - - env.configureVolumesAndMounts(&vols, &mnts) - - assert.Len(t, vols, 3) - assert.Len(t, mnts, 3) - - v := findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "test-configmap" }) - assert.NotNil(t, v) - assert.NotNil(t, v.VolumeSource.ConfigMap) - assert.NotNil(t, v.VolumeSource.ConfigMap.LocalObjectReference) - assert.Equal(t, "test-configmap", v.VolumeSource.ConfigMap.LocalObjectReference.Name) - - m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-configmap" }) - assert.NotNil(t, m) - assert.Equal(t, filepath.Join(camel.ConfigConfigmapsMountPath, "test-configmap"), m.MountPath) - - v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "test-secret" }) - assert.NotNil(t, v) - assert.NotNil(t, v.Secret) - assert.Equal(t, "test-secret", v.Secret.SecretName) - - m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-secret" }) - assert.NotNil(t, m) - assert.Equal(t, filepath.Join(camel.ConfigSecretsMountPath, "test-secret"), m.MountPath) - - v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "testvolume-data" }) - assert.NotNil(t, v) - assert.NotNil(t, v.VolumeSource) - assert.NotNil(t, v.VolumeSource.PersistentVolumeClaim) - assert.Equal(t, "testvolume", v.VolumeSource.PersistentVolumeClaim.ClaimName) - - m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "testvolume-data" }) - assert.NotNil(t, m) - assert.Equal(t, "/foo/bar", m.MountPath) -} - func TestConfigureVolumesAndMountsSources(t *testing.T) { env := Environment{ Resources: kubernetes.NewCollection(), diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go index d52acc674f..c4028faae5 100644 --- a/pkg/trait/trait_types.go +++ b/pkg/trait/trait_types.go @@ -569,48 +569,6 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c } }) } - - // Deprecated - should use mount trait - // User provided configmaps - for _, configmaps := range e.collectConfigurations("configmap") { - refName := kubernetes.SanitizeLabel(configmaps["value"]) - mountPath := getMountPoint(configmaps["value"], configmaps["resourceMountPoint"], configmapStorageType, configmaps["resourceType"]) - vol := getVolume(refName, configmapStorageType, configmaps["value"], configmaps["resourceKey"], configmaps["resourceKey"]) - mnt := getMount(refName, mountPath, "", true) - - *vols = append(*vols, *vol) - *mnts = append(*mnts, *mnt) - } - - // Deprecated - should use mount trait - // User provided secrets - for _, secret := range e.collectConfigurations("secret") { - refName := kubernetes.SanitizeLabel(secret["value"]) - mountPath := getMountPoint(secret["value"], secret["resourceMountPoint"], secretStorageType, secret["resourceType"]) - vol := getVolume(refName, secretStorageType, secret["value"], secret["resourceKey"], secret["resourceKey"]) - mnt := getMount(refName, mountPath, "", true) - - *vols = append(*vols, *vol) - *mnts = append(*mnts, *mnt) - } - // Deprecated - should use mount trait - // User provided volumes - for _, volumeConfig := range e.collectConfigurationValues("volume") { - configParts := strings.Split(volumeConfig, ":") - - if len(configParts) != 2 { - continue - } - - pvcName := configParts[0] - mountPath := configParts[1] - volumeName := pvcName + "-data" - - vol := getVolume(volumeName, pvcStorageType, pvcName, "", "") - mnt := getMount(volumeName, mountPath, "", false) - *vols = append(*vols, *vol) - *mnts = append(*mnts, *mnt) - } } func getVolume(volName, storageType, storageName, filterKey, filterValue string) *corev1.Volume { @@ -692,10 +650,6 @@ func getMountPoint(resourceName string, mountPoint string, storagetype, resource return filepath.Join(defaultMountPoint, resourceName) } -func (e *Environment) collectConfigurationValues(configurationType string) []string { - return collectConfigurationValues(configurationType, e.Platform, e.IntegrationKit, e.Integration) -} - type variable struct { Name, Value string } @@ -704,10 +658,6 @@ func (e *Environment) collectConfigurationPairs(configurationType string) []vari return collectConfigurationPairs(configurationType, e.Platform, e.IntegrationKit, e.Integration) } -func (e *Environment) collectConfigurations(configurationType string) []map[string]string { - return collectConfigurations(configurationType, e.Platform, e.IntegrationKit, e.Integration) -} - func (e *Environment) GetIntegrationContainerName() string { containerName := defaultContainerName diff --git a/pkg/trait/trait_types_test.go b/pkg/trait/trait_types_test.go index 6397995c44..497cd034af 100644 --- a/pkg/trait/trait_types_test.go +++ b/pkg/trait/trait_types_test.go @@ -77,11 +77,6 @@ func TestCollectConfigurationValues(t *testing.T) { }, } e.Platform.ResyncStatusFullConfig() - - assert.Contains(t, e.collectConfigurationValues("configmap"), "my-cm-integration") - assert.Contains(t, e.collectConfigurationValues("secret"), "my-secret-platform") - assert.Contains(t, e.collectConfigurationValues("property"), "my-p-kit") - assert.Contains(t, e.collectConfigurationValues("env"), "my-env-integration") } func TestCollectConfigurationPairs(t *testing.T) { diff --git a/pkg/trait/util.go b/pkg/trait/util.go index f81dfa5ed4..1ed81bbc31 100644 --- a/pkg/trait/util.go +++ b/pkg/trait/util.go @@ -24,7 +24,6 @@ import ( "fmt" "reflect" "regexp" - "sort" "strings" ctrl "sigs.k8s.io/controller-runtime/pkg/client" @@ -75,56 +74,6 @@ func getIntegrationKit(ctx context.Context, c client.Client, integration *v1.Int return kit, err } -func collectConfigurationValues(configurationType string, configurable ...v1.Configurable) []string { - result := sets.NewSet() - - for _, c := range configurable { - if c == nil || reflect.ValueOf(c).IsNil() { - continue - } - - entries := c.Configurations() - if entries == nil { - continue - } - - for _, entry := range entries { - if entry.Type == configurationType { - result.Add(entry.Value) - } - } - } - - s := result.List() - sort.Strings(s) - return s -} - -func collectConfigurations(configurationType string, configurable ...v1.Configurable) []map[string]string { - var result []map[string]string - - for _, c := range configurable { - if c == nil || reflect.ValueOf(c).IsNil() { - continue - } - - entries := c.Configurations() - if entries == nil { - continue - } - - for _, entry := range entries { - if entry.Type == configurationType { - item := make(map[string]string) - item["value"] = entry.Value - result = append(result, item) - } - } - } - - return result -} - func collectConfigurationPairs(configurationType string, configurable ...v1.Configurable) []variable { result := make([]variable, 0) @@ -524,7 +473,7 @@ func NewSpecTraitsOptionsForIntegrationAndPlatform(c client.Client, i *v1.Integr } // Deprecated: to remove when we remove support for traits annotations. - // IMPORTANT: when we remove this we'll need to remove the cli from the func, + // IMPORTANT: when we remove this we'll need to remove the client.Client from the func, // which will bring to more cascade removal. It had to be introduced to support the deprecated feature // in a properly manner (ie, comparing the spec.traits with annotations in a proper way). return newTraitsOptions(c, options, i.ObjectMeta.Annotations) @@ -537,7 +486,7 @@ func NewSpecTraitsOptionsForIntegration(c client.Client, i *v1.Integration) (Opt } // Deprecated: to remove when we remove support for traits annotations. - // IMPORTANT: when we remove this we'll need to remove the cli from the func, + // IMPORTANT: when we remove this we'll need to remove the client.Client from the func, // which will bring to more cascade removal. It had to be introduced to support the deprecated feature // in a properly manner (ie, comparing the spec.traits with annotations in a proper way). return newTraitsOptions(c, m1, i.ObjectMeta.Annotations) @@ -550,7 +499,7 @@ func newTraitsOptionsForIntegrationKit(c client.Client, i *v1.IntegrationKit, tr } // Deprecated: to remove when we remove support for traits annotations. - // IMPORTANT: when we remove this we'll need to remove the cli from the func, + // IMPORTANT: when we remove this we'll need to remove the client.Client from the func, // which will bring to more cascade removal. It had to be introduced to support the deprecated feature // in a properly manner (ie, comparing the spec.traits with annotations in a proper way). return newTraitsOptions(c, m1, i.ObjectMeta.Annotations)