You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/02/10 10:54:44 UTC

[camel-k] 01/02: feature(#3903): Support secret refresh through the existing addons - AWS Secrets Manager

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch 3903-aws
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d187b8d48b38380faf03a47e35e238e051a960f1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Feb 10 11:51:44 2023 +0100

    feature(#3903): Support secret refresh through the existing addons - AWS Secrets Manager
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 addons/vault/aws/aws_secrets_manager.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/addons/vault/aws/aws_secrets_manager.go b/addons/vault/aws/aws_secrets_manager.go
index 33bbc8c26..e9f12ec08 100644
--- a/addons/vault/aws/aws_secrets_manager.go
+++ b/addons/vault/aws/aws_secrets_manager.go
@@ -50,6 +50,14 @@ type Trait struct {
 	Region string `property:"region,omitempty"`
 	// Define if we want to use the Default Credentials Provider chain as authentication method
 	UseDefaultCredentialsProvider *bool `property:"use-default-credentials-provider,omitempty"`
+	// Define if we want to use the Camel Context Reload feature or not
+	ContextReloadEnabled *bool `property:"context-reload-enabled,omitempty"`
+	// Define if we want to use the Refresh Feature for secrets
+	RefreshEnabled *bool `property:"refresh-enabled,omitempty"`
+	// If Refresh is enabled, this defines the interval to check the refresh event
+	RefreshPeriod string `property:"refresh-period,omitempty"`
+	// If Refresh is enabled, the regular expression representing the secrets we want to track
+	Secrets string `property:"refresh-period,omitempty"`
 }
 
 type awsSecretsManagerTrait struct {
@@ -75,6 +83,12 @@ func (t *awsSecretsManagerTrait) Configure(environment *trait.Environment) (bool
 	if t.UseDefaultCredentialsProvider == nil {
 		t.UseDefaultCredentialsProvider = pointer.Bool(false)
 	}
+	if t.ContextReloadEnabled == nil {
+		t.ContextReloadEnabled = pointer.Bool(false)
+	}
+	if t.RefreshEnabled == nil {
+		t.RefreshEnabled = pointer.Bool(false)
+	}
 
 	return true, nil
 }
@@ -91,6 +105,12 @@ func (t *awsSecretsManagerTrait) Apply(environment *trait.Environment) error {
 		environment.ApplicationProperties["camel.vault.aws.secretKey"] = t.SecretKey
 		environment.ApplicationProperties["camel.vault.aws.region"] = t.Region
 		environment.ApplicationProperties["camel.vault.aws.defaultCredentialsProvider"] = strconv.FormatBool(*t.UseDefaultCredentialsProvider)
+		environment.ApplicationProperties["camel.vault.aws.refreshEnabled"] = strconv.FormatBool(*t.RefreshEnabled)
+		environment.ApplicationProperties["camel.main.context-reload-enabled"] = strconv.FormatBool(*t.ContextReloadEnabled)
+		environment.ApplicationProperties["camel.vault.aws.refreshPeriod"] = t.RefreshPeriod
+		if t.Secrets != "" {
+			environment.ApplicationProperties["camel.vault.aws.secrets"] = t.Secrets
+		}
 	}
 
 	return nil