Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove code deprecated before 2.3 #5770

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.


|===
Expand Down
5 changes: 1 addition & 4 deletions docs/modules/traits/pages/mount.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

|===

Expand Down
40 changes: 0 additions & 40 deletions e2e/common/config/kamelet_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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())
Expand Down
23 changes: 0 additions & 23 deletions e2e/common/config/pipe_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions pkg/apis/camel/v1/trait/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 0 additions & 66 deletions pkg/trait/kamelets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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, ",") {
Expand All @@ -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 "<kamelet-name>.extension"
Expand Down
25 changes: 0 additions & 25 deletions pkg/trait/kamelets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
15 changes: 10 additions & 5 deletions pkg/trait/knative_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
},
},
Expand Down
Loading