Skip to content
New issue

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

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

Already on GitHub? # to your account

feature(#3903): Support secret refresh through the existing addons - Azure Key Vault #4056

Merged
merged 4 commits into from
Feb 13, 2023
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
36 changes: 36 additions & 0 deletions addons/vault/azure/azure_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.
package azure

import (
"strconv"

v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/pkg/trait"
Expand Down Expand Up @@ -48,6 +50,22 @@ type Trait struct {
ClientSecret string `property:"client-secret,omitempty"`
// The Azure Vault Name for accessing Key Vault
VaultName string `property:"vault-name,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, the connection String to point to the Eventhub service used to track updates
EventhubConnectionString string `property:"refresh-period,omitempty"`
// If Refresh is enabled, the account name for Azure Storage Blob service used to save checkpoint while consuming from Eventhub
BlobAccountName string `property:"refresh-period,omitempty"`
// If Refresh is enabled, the access key for Azure Storage Blob service used to save checkpoint while consuming from Eventhub
BlobAccessKey string `property:"refresh-period,omitempty"`
// If Refresh is enabled, the container name for Azure Storage Blob service used to save checkpoint while consuming from Eventhub
BlobContainerName string `property:"refresh-period,omitempty"`
}

type azureKeyVaultTrait struct {
Expand All @@ -70,6 +88,14 @@ func (t *azureKeyVaultTrait) Configure(environment *trait.Environment) (bool, er
return false, nil
}

if t.ContextReloadEnabled == nil {
t.ContextReloadEnabled = pointer.Bool(false)
}

if t.RefreshEnabled == nil {
t.RefreshEnabled = pointer.Bool(false)
}

return true, nil
}

Expand All @@ -85,6 +111,16 @@ func (t *azureKeyVaultTrait) Apply(environment *trait.Environment) error {
environment.ApplicationProperties["camel.vault.azure.clientId"] = t.ClientID
environment.ApplicationProperties["camel.vault.azure.clientSecret"] = t.ClientSecret
environment.ApplicationProperties["camel.vault.azure.vaultName"] = t.VaultName
environment.ApplicationProperties["camel.vault.azure.refreshEnabled"] = strconv.FormatBool(*t.RefreshEnabled)
environment.ApplicationProperties["camel.main.context-reload-enabled"] = strconv.FormatBool(*t.ContextReloadEnabled)
environment.ApplicationProperties["camel.vault.azure.refreshPeriod"] = t.RefreshPeriod
if t.Secrets != "" {
environment.ApplicationProperties["camel.vault.azure.secrets"] = t.Secrets
}
environment.ApplicationProperties["camel.vault.azure.eventhubConnectionString"] = t.EventhubConnectionString
environment.ApplicationProperties["camel.vault.azure.blobAccountName"] = t.BlobAccountName
environment.ApplicationProperties["camel.vault.azure.blobContainerName"] = t.BlobContainerName
environment.ApplicationProperties["camel.vault.azure.blobAccessKey"] = t.BlobAccessKey
}

return nil
Expand Down
32 changes: 32 additions & 0 deletions docs/modules/traits/pages/azure-key-vault.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,38 @@ The following configuration options are available:
| string
| The Azure Vault Name for accessing Key Vault

| azure-key-vault.context-reload-enabled,omitempty
| bool
| Define if we want to use the Camel Context Reload feature or not

| azure-key-vault.refresh-enabled,omitempty
| bool
| Define if we want to use the Refresh Feature for secrets

| azure-key-vault.refresh-period,omitempty
| string
| If Refresh is enabled, this defines the interval to check the refresh event

| azure-key-vault.refresh-period,omitempty
| string
| If Refresh is enabled, the regular expression representing the secrets we want to track

| azure-key-vault.refresh-period,omitempty
| string
| If Refresh is enabled, the connection String to point to the Eventhub service used to track updates

| azure-key-vault.refresh-period,omitempty
| string
| If Refresh is enabled, the account name for Azure Storage Blob service used to save checkpoint while consuming from Eventhub

| azure-key-vault.refresh-period,omitempty
| string
| If Refresh is enabled, the access key for Azure Storage Blob service used to save checkpoint while consuming from Eventhub

| azure-key-vault.refresh-period,omitempty
| string
| If Refresh is enabled, the container name for Azure Storage Blob service used to save checkpoint while consuming from Eventhub

|===

// End of autogenerated code - DO NOT EDIT! (configuration)
4 changes: 2 additions & 2 deletions pkg/resources/resources.go

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions resources/traits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@ traits:
- name: vault-name,omitempty
type: string
description: The Azure Vault Name for accessing Key Vault
- name: context-reload-enabled,omitempty
type: bool
description: Define if we want to use the Camel Context Reload feature or not
- name: refresh-enabled,omitempty
type: bool
description: Define if we want to use the Refresh Feature for secrets
- name: refresh-period,omitempty
type: string
description: If Refresh is enabled, this defines the interval to check the refresh
event
- name: refresh-period,omitempty
type: string
description: If Refresh is enabled, the regular expression representing the secrets
we want to track
- name: refresh-period,omitempty
type: string
description: If Refresh is enabled, the connection String to point to the Eventhub
service used to track updates
- name: refresh-period,omitempty
type: string
description: If Refresh is enabled, the account name for Azure Storage Blob service
used to save checkpoint while consuming from Eventhub
- name: refresh-period,omitempty
type: string
description: If Refresh is enabled, the access key for Azure Storage Blob service
used to save checkpoint while consuming from Eventhub
- name: refresh-period,omitempty
type: string
description: If Refresh is enabled, the container name for Azure Storage Blob
service used to save checkpoint while consuming from Eventhub
- name: builder
platform: true
profiles:
Expand Down