Skip to content

Commit

Permalink
feature(#3903): Support secret refresh through the existing addons - …
Browse files Browse the repository at this point in the history
…AWS Secrets Manager

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
  • Loading branch information
oscerd committed Feb 10, 2023
1 parent a1f7668 commit d187b8d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions addons/vault/aws/aws_secrets_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit d187b8d

Please sign in to comment.