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

feat(trait): service label and deprecations #5906

Merged
merged 9 commits into from
Oct 27, 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
15 changes: 14 additions & 1 deletion addons/resume/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/v2/pkg/trait"
"github.com/apache/camel-k/v2/pkg/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
)

Expand All @@ -33,6 +34,8 @@ import (
//
// The Resume trait is disabled by default.
//
// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
//
// The main different from the implementation on Core is that it's not necessary to bind the strategies to the
// registry. This step will be done automatically by Camel K, after resolving the options passed to the trait.
//
Expand All @@ -41,6 +44,7 @@ import (
// -t resume.enabled=true -t resume.resume-path=camel-file-sets -t resume.resume-server="address-of-your-kafka:9092"
//
// +camel-k:trait=resume.
// +camel-k:deprecated=2.5.0.
type Trait struct {
traitv1.Trait `property:",squash"`
// Enables automatic configuration of the trait.
Expand Down Expand Up @@ -81,7 +85,16 @@ func (r *resumeTrait) Configure(environment *trait.Environment) (bool, *trait.Tr
return false, nil, nil
}

return ptr.Deref(r.Enabled, false), nil, nil
condition := trait.NewIntegrationCondition(
"Resume",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
trait.TraitConfigurationReason,
"Resume trait is deprecated and may be removed in future version: "+
"configure directly the Camel properties as required by the component instead",
)

return ptr.Deref(r.Enabled, false), condition, nil
}

func (r *resumeTrait) Apply(environment *trait.Environment) error {
Expand Down
15 changes: 14 additions & 1 deletion addons/threescale/3scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package threescale
import (
"strconv"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"

Expand All @@ -33,7 +34,10 @@ import (
//
// The 3scale trait is disabled by default.
//
// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
//
// +camel-k:trait=3scale.
// +camel-k:deprecated=2.5.0.
type Trait struct {
traitv1.Trait `property:",squash" json:",inline"`
// Enables automatic configuration of the trait.
Expand Down Expand Up @@ -95,6 +99,15 @@ func (t *threeScaleTrait) Configure(e *trait.Environment) (bool, *trait.TraitCon
return false, nil, nil
}

condition := trait.NewIntegrationCondition(
"3Scale",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
trait.TraitConfigurationReason,
"3Scale trait is deprecated and may be removed in future version: "+
"use service trait to add 3Scale labels and annotations instead",
)

if ptr.Deref(t.Auto, true) {
if t.Scheme == "" {
t.Scheme = ThreeScaleSchemeDefaultValue
Expand All @@ -111,7 +124,7 @@ func (t *threeScaleTrait) Configure(e *trait.Environment) (bool, *trait.TraitCon
}
}

return true, nil, nil
return true, condition, nil
}

func (t *threeScaleTrait) Apply(e *trait.Environment) error {
Expand Down
4 changes: 2 additions & 2 deletions addons/threescale/3scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestThreeScaleInjection(t *testing.T) {
ok, condition, err := threeScale.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = threeScale.Apply(e)
require.NoError(t, err)
Expand All @@ -75,7 +75,7 @@ func TestThreeScaleInjectionNoAPIPath(t *testing.T) {
ok, condition, err := threeScale.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = threeScale.Apply(e)
require.NoError(t, err)
Expand Down
15 changes: 14 additions & 1 deletion addons/vault/aws/aws_secrets_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/v2/pkg/trait"
"github.com/apache/camel-k/v2/pkg/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
)

Expand All @@ -43,7 +44,10 @@ import (
// the following trait options:
// -t aws-secrets-manager.enabled=true -t aws-secrets-manager.access-key="aws-access-key" -t aws-secrets-manager.secret-key="aws-secret-key" -t aws-secrets-manager.region="aws-region" -t aws-secrets-manager.context-reload-enabled="true" -t aws-secrets-manager.refresh-enabled="true" -t aws-secrets-manager.refresh-period="30000" -t aws-secrets-manager.secrets="test*"
//
// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
//
// +camel-k:trait=aws-secrets-manager.
// +camel-k:deprecated=2.5.0.
type Trait struct {
traitv1.Trait `property:",squash"`
// Enables automatic configuration of the trait.
Expand Down Expand Up @@ -100,7 +104,16 @@ func (t *awsSecretsManagerTrait) Configure(environment *trait.Environment) (bool
t.RefreshEnabled = ptr.To(false)
}

return true, nil, nil
condition := trait.NewIntegrationCondition(
"AWSSecretManager",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
trait.TraitConfigurationReason,
"AWSSecretManager trait is deprecated and may be removed in future version: "+
"configure directly the Camel properties as required by the component instead",
)

return true, condition, nil
}

func (t *awsSecretsManagerTrait) Apply(environment *trait.Environment) error {
Expand Down
8 changes: 4 additions & 4 deletions addons/vault/aws/aws_secrets_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAwsSecretsManagerTraitApply(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand All @@ -72,7 +72,7 @@ func TestAwsSecretsManagerTraitNoDefaultCreds(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestAwsSecretsManagerTraitWithSecrets(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestAwsSecretsManagerTraitWithConfigMap(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down
15 changes: 14 additions & 1 deletion addons/vault/azure/azure_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/v2/pkg/trait"
"github.com/apache/camel-k/v2/pkg/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
)

Expand All @@ -43,7 +44,10 @@ import (
// the following trait options:
// -t azure-key-vault.enabled=true -t azure-key-vault.tenant-id="tenant-id" -t azure-key-vault.client-id="client-id" -t azure-key-vault.client-secret="client-secret" -t azure-key-vault.vault-name="vault-name" -t azure-key-vault.context-reload-enabled="true" -t azure-key-vault.refresh-enabled="true" -t azure-key-vault.refresh-period="30000" -t azure-key-vault.secrets="test*" -t azure-key-vault.eventhub-connection-string="connection-string" -t azure-key-vault.blob-account-name="account-name" -t azure-key-vault.blob-container-name="container-name" -t azure-key-vault.blob-access-key="account-name" -t azure-key-vault.azure-identity-enabled="true"
//
// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
//
// +camel-k:trait=azure-key-vault.
// +camel-k:deprecated=2.5.0.
type Trait struct {
traitv1.Trait `property:",squash"`
// Enables automatic configuration of the trait.
Expand Down Expand Up @@ -112,7 +116,16 @@ func (t *azureKeyVaultTrait) Configure(environment *trait.Environment) (bool, *t
t.AzureIdentityEnabled = ptr.To(false)
}

return true, nil, nil
condition := trait.NewIntegrationCondition(
"AzureKeyVault",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
trait.TraitConfigurationReason,
"AzureKeyVault trait is deprecated and may be removed in future version: "+
"configure directly the Camel properties as required by the component instead",
)

return true, condition, nil
}

func (t *azureKeyVaultTrait) Apply(environment *trait.Environment) error {
Expand Down
8 changes: 4 additions & 4 deletions addons/vault/azure/azure_key_vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestAzureKeyVaultTraitApply(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestAzureKeyVaultTraitApplyWithConfigmapAndRefresh(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestAzureKeyVaultTraitApplyWithSecretAndRefresh(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestAzureKeyVaultTraitAzureIdentityEnabledApplyWithSecretAndRefresh(t *test
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down
15 changes: 14 additions & 1 deletion addons/vault/gcp/gcp_secret_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/v2/pkg/trait"
"github.com/apache/camel-k/v2/pkg/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
)

Expand All @@ -41,7 +42,10 @@ import (
// the following trait options:
// -t gpc-secret-manager.enabled=true -t gpc-secret-manager.project-id="project-id" -t gpc-secret-manager.service-account-key="file:serviceaccount.json" -t gcp-secret-manager.subscription-name="pubsub-sub" -t gcp-secret-manager.context-reload-enabled="true" -t gcp-secret-manager.refresh-enabled="true" -t gcp-secret-manager.refresh-period="30000" -t gcp-secret-manager.secrets="test*"
//
// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
//
// +camel-k:trait=gcp-secret-manager.
// +camel-k:deprecated=2.5.0.
type Trait struct {
traitv1.Trait `property:",squash"`
// Enables automatic configuration of the trait.
Expand Down Expand Up @@ -96,7 +100,16 @@ func (t *gcpSecretManagerTrait) Configure(environment *trait.Environment) (bool,
t.RefreshEnabled = ptr.To(false)
}

return true, nil, nil
condition := trait.NewIntegrationCondition(
"GCPSecretManager",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
trait.TraitConfigurationReason,
"GCPSecretManager trait is deprecated and may be removed in future version: "+
"configure directly the Camel properties as required by the component instead",
)

return true, condition, nil
}

func (t *gcpSecretManagerTrait) Apply(environment *trait.Environment) error {
Expand Down
4 changes: 2 additions & 2 deletions addons/vault/gcp/gcp_secret_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestGcpSecretManagerTraitApply(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand All @@ -65,7 +65,7 @@ func TestGcpSecretManagerTraitNoDefaultCreds(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down
15 changes: 14 additions & 1 deletion addons/vault/hashicorp/hashicorp_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/apache/camel-k/v2/pkg/trait"
"github.com/apache/camel-k/v2/pkg/util"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
)

Expand All @@ -36,7 +37,10 @@ import (
// the following trait options:
// -t hashicorp-vault.enabled=true -t hashicorp-vault.token="token" -t hashicorp-vault.port="port" -t hashicorp-vault.engine="engine" -t hashicorp-vault.port="port" -t hashicorp-vault.scheme="scheme"
//
// WARNING: The trait is **deprecated** and will removed in future release versions: configure directly the Camel properties as required by the component instead.
//
// +camel-k:trait=hashicorp-vault.
// +camel-k:deprecated=2.5.0.
type Trait struct {
traitv1.Trait `property:",squash"`
// Enables automatic configuration of the trait.
Expand Down Expand Up @@ -75,7 +79,16 @@ func (t *hashicorpVaultTrait) Configure(environment *trait.Environment) (bool, *
return false, nil, nil
}

return true, nil, nil
condition := trait.NewIntegrationCondition(
"HashicorpVault",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
trait.TraitConfigurationReason,
"HashicorpVault trait is deprecated and may be removed in future version: "+
"configure directly the Camel properties as required by the component instead",
)

return true, condition, nil
}

func (t *hashicorpVaultTrait) Apply(environment *trait.Environment) error {
Expand Down
6 changes: 3 additions & 3 deletions addons/vault/hashicorp/hashicorp_vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestHashicorpVaultTraitApply(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestHashicorpVaultTraitWithSecretApply(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestHashicorpVaultTraitWithConfigMapApply(t *testing.T) {
ok, condition, err := secrets.Configure(e)
require.NoError(t, err)
assert.True(t, ok)
assert.Nil(t, condition)
assert.NotNil(t, condition)

err = secrets.Apply(e)
require.NoError(t, err)
Expand Down
7 changes: 7 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8797,6 +8797,13 @@ map[string]string

The annotations added to the Service object.

|`labels` +
map[string]string
|


The labels added to the Service object.


|===

Expand Down
Loading