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/13 06:58:24 UTC

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

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

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

commit 98d937b455023e71a1b0930e6408f04ac0f56d8d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Feb 13 07:54:10 2023 +0100

    feature(#3903): Support secret refresh through the existing addons - Google Secret Manager
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 addons/vault/gcp/gcp_secret_manager.go | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/addons/vault/gcp/gcp_secret_manager.go b/addons/vault/gcp/gcp_secret_manager.go
index 0b832d682..910565dac 100644
--- a/addons/vault/gcp/gcp_secret_manager.go
+++ b/addons/vault/gcp/gcp_secret_manager.go
@@ -48,6 +48,16 @@ type Trait struct {
 	ServiceAccountKey string `property:"service-account-key,omitempty"`
 	// Define if we want to use the Default Instance approach for accessing the Google Secret Manager service
 	UseDefaultInstance *bool `property:"use-default-instance,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"`
+	// If Refresh is enabled, this defines the subscription name to the Google PubSub topic used to keep track of updates
+	SubscriptionName string `property:"refresh-period,omitempty"`
 }
 
 type gcpSecretManagerTrait struct {
@@ -74,6 +84,14 @@ func (t *gcpSecretManagerTrait) Configure(environment *trait.Environment) (bool,
 		t.UseDefaultInstance = pointer.Bool(false)
 	}
 
+	if t.ContextReloadEnabled == nil {
+		t.ContextReloadEnabled = pointer.Bool(false)
+	}
+	
+	if t.RefreshEnabled == nil {
+		t.RefreshEnabled = pointer.Bool(false)
+	}
+
 	return true, nil
 }
 
@@ -88,6 +106,13 @@ func (t *gcpSecretManagerTrait) Apply(environment *trait.Environment) error {
 		environment.ApplicationProperties["camel.vault.gcp.projectId"] = t.ProjectID
 		environment.ApplicationProperties["camel.vault.gcp.serviceAccountKey"] = t.ServiceAccountKey
 		environment.ApplicationProperties["camel.vault.gcp.useDefaultInstance"] = strconv.FormatBool(*t.UseDefaultInstance)
+		environment.ApplicationProperties["camel.vault.gcp.refreshEnabled"] = strconv.FormatBool(*t.RefreshEnabled)
+		environment.ApplicationProperties["camel.main.context-reload-enabled"] = strconv.FormatBool(*t.ContextReloadEnabled)
+		environment.ApplicationProperties["camel.vault.gcp.refreshPeriod"] = t.RefreshPeriod
+		environment.ApplicationProperties["camel.vault.gcp.subscriptionName"] = t.SubscriptionName
+		if t.Secrets != "" {
+			environment.ApplicationProperties["camel.vault.gcp.secrets"] = t.Secrets
+		}
 	}
 
 	return nil