Skip to content

Commit 423cdde

Browse files
authored
Merge pull request #495 from dquagebeur/feature/azurekv
2 parents 608531e + 9f76861 commit 423cdde

8 files changed

Lines changed: 880 additions & 158 deletions

File tree

controllers/kustomization_decryptor.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"sigs.k8s.io/yaml"
4343

4444
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
45+
"github.com/fluxcd/kustomize-controller/internal/sops/azkv"
4546
intkeyservice "github.com/fluxcd/kustomize-controller/internal/sops/keyservice"
4647
)
4748

@@ -50,14 +51,18 @@ const (
5051
DecryptionProviderSOPS = "sops"
5152
// DecryptionVaultTokenFileName is the name of the file containing the Vault token
5253
DecryptionVaultTokenFileName = "sops.vault-token"
54+
// DecryptionAzureAuthFile is the Azure authentication file
55+
DecryptionAzureAuthFile = "sops.azure-kv"
5356
)
5457

5558
type KustomizeDecryptor struct {
5659
client.Client
57-
kustomization kustomizev1.Kustomization
58-
homeDir string
59-
ageIdentities []string
60-
vaultToken string
60+
61+
kustomization kustomizev1.Kustomization
62+
homeDir string
63+
ageIdentities []string
64+
vaultToken string
65+
azureAADConfig *azkv.AADConfig
6166
}
6267

6368
func NewDecryptor(kubeClient client.Client,
@@ -155,6 +160,14 @@ func (kd *KustomizeDecryptor) ImportKeys(ctx context.Context) error {
155160
var ageIdentities []string
156161
var vaultToken string
157162
for name, value := range secret.Data {
163+
if name == DecryptionAzureAuthFile {
164+
azureConf := azkv.AADConfig{}
165+
if err = azkv.LoadAADConfigFromBytes(value, &azureConf); err != nil {
166+
return err
167+
}
168+
kd.azureAADConfig = &azureConf
169+
continue
170+
}
158171
switch filepath.Ext(name) {
159172
case ".asc":
160173
keyPath, err := securejoin.SecureJoin(tmpDir, name)
@@ -272,7 +285,7 @@ func (kd KustomizeDecryptor) DataWithFormat(data []byte, inputFormat, outputForm
272285

273286
metadataKey, err := tree.Metadata.GetDataKeyWithKeyServices(
274287
[]keyservice.KeyServiceClient{
275-
intkeyservice.NewLocalClient(intkeyservice.NewServer(false, kd.homeDir, kd.vaultToken, kd.ageIdentities)),
288+
intkeyservice.NewLocalClient(intkeyservice.NewServer(false, kd.homeDir, kd.vaultToken, kd.ageIdentities, kd.azureAADConfig)),
276289
},
277290
)
278291
if err != nil {

0 commit comments

Comments
 (0)