Skip to content

Commit 9f0165b

Browse files
authored
feat: Azure KeyVault support (#388)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent a071919 commit 9f0165b

File tree

15 files changed

+1007
-63
lines changed

15 files changed

+1007
-63
lines changed

app/artifact-cas/configs/samples/config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ credentials_service:
3333
# project_id: 522312304548
3434
# auth_key: "./configs/gcp_auth_key.json"
3535

36+
# azure_key_vault:
37+
# tenant_id: AD-tenant-id
38+
# client_id: Service Principal ID
39+
# client_secret: Service Principal Secret
40+
# vault_uri: https://myvault.vault.azure.net/
41+
3642
observability:
3743
sentry:
3844
dsn: "http://sentryDomain"

app/controlplane/configs/samples/config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ credentials_service:
4040

4141
# gcp_secret_manager:
4242
# project_id: 522312304548
43-
# auth_key: "./configs/gcp_auth_key.json"
43+
# auth_key: "./configs/gcp_auth_key.json"
44+
45+
# azure_key_vault:
46+
# tenant_id: AD-tenant-id
47+
# client_id: Service Principal ID
48+
# client_secret: Service Principal Secret
49+
# vault_uri: https://myvault.vault.azure.net/

app/controlplane/internal/biz/casbackend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func (uc *CASBackendUseCase) Delete(ctx context.Context, id string) error {
386386
uc.logger.Infow("msg", "deleting CAS backend external secrets", "ID", id, "secretName", backend.SecretName)
387387
// Delete the secret in the external secrets manager
388388
if err := uc.credsRW.DeleteCredentials(ctx, backend.SecretName); err != nil {
389-
return fmt.Errorf("deleting the credentials: %w", err)
389+
uc.logger.Errorw("msg", "deleting CAS backend external secrets", "ID", id, "secretName", backend.SecretName, "error", err)
390390
}
391391

392392
uc.logger.Infow("msg", "CAS Backend deleted", "ID", id)

app/controlplane/internal/biz/organization.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package biz
1717

1818
import (
1919
"context"
20+
"fmt"
2021
"time"
2122

2223
"github.com/go-kratos/kratos/v2/log"
@@ -101,18 +102,14 @@ func (uc *OrganizationUseCase) Delete(ctx context.Context, id string) error {
101102
}
102103
}
103104

104-
// Delete the associated repository
105-
// Currently there is only one repository per organization
106-
ociRepository, err := uc.casBackendUseCase.FindDefaultBackend(ctx, org.ID)
107-
if err != nil && !IsNotFound(err) {
108-
return err
105+
backends, err := uc.casBackendUseCase.List(ctx, org.ID)
106+
if err != nil {
107+
return fmt.Errorf("failed to list backends: %w", err)
109108
}
110109

111-
if ociRepository != nil {
112-
// We make sure to call the OCI repository use case to delete the repository
113-
// including the external secret
114-
if err := uc.casBackendUseCase.Delete(ctx, ociRepository.ID.String()); err != nil {
115-
return err
110+
for _, b := range backends {
111+
if err := uc.casBackendUseCase.Delete(ctx, b.ID.String()); err != nil {
112+
return fmt.Errorf("failed to delete backend: %w", err)
116113
}
117114
}
118115

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ require (
8282
cloud.google.com/go/pubsub v1.33.0 // indirect
8383
dario.cat/mergo v1.0.0 // indirect
8484
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
85+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.7.1 // indirect
8586
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
8687
github.com/acomagu/bufpipe v1.0.4 // indirect
8788
github.com/anchore/go-struct-converter v0.0.0-20230627203149-c72ef8859ca9 // indirect
@@ -123,6 +124,7 @@ require (
123124
cloud.google.com/go/compute v1.23.0 // indirect
124125
cloud.google.com/go/compute/metadata v0.2.3 // indirect
125126
cloud.google.com/go/iam v1.1.2 // indirect
127+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.12.0
126128
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
127129
github.com/Microsoft/go-winio v0.6.1 // indirect
128130
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybI
9090
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U=
9191
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
9292
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM=
93+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.12.0 h1:xnO4sFyG8UH2fElBkcqLTOZsAajvKfnSlgBBW8dXYjw=
94+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.12.0/go.mod h1:XD3DIOOVgBCO03OleB1fHjgktVRFxlT++KwKgIOewdM=
95+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.7.1 h1:FbH3BbSb4bvGluTesZZ+ttN/MDsnMmQP36OSnDuSXqw=
96+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.7.1/go.mod h1:9V2j0jn9jDEkCkv8w/bKTNppX/d0FVA1ud77xCIP4KA=
9397
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8=
9498
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0/go.mod h1:c+Lifp3EDEamAkPVzMooRNOK6CZjNSdEnf1A7jsI9u4=
9599
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 h1:yfJe15aSwEQ6Oo6J+gdfdulPNoZ3TEhmbhLIoxZcA+U=

0 commit comments

Comments
 (0)