Skip to content

Commit 5ab89e1

Browse files
committed
Refactor the Azure plugin
Both Kopia repository and Azure plugin need to interact with Azure storage. In order to keep in sync with the new features for both these two places and remove duplicated code, PR vmware-tanzu/velero#6686 makes the common code as util functions in Velero repository. This commit refactors the Azure plugin based on these util functions. Signed-off-by: Wenkai Yin(尹文开) <[email protected]>
1 parent 5ac1aab commit 5ab89e1

File tree

8 files changed

+132
-518
lines changed

8 files changed

+132
-518
lines changed

README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ There are two ways to specify the role: use the built-in role or create a custom
287287
AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET}
288288
AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
289289
AZURE_CLOUD_NAME=AzurePublicCloud
290-
AZURE_ENVIRONMENT=AzurePublicCloud
291290
EOF
292291
```
293292
294-
> Available values for `AZURE_CLOUD_NAME` and `AZURE_ENVIRONMENT`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`. `AZURE_ENVIRONMENT` is NOT required for `AzurePublicCloud`
293+
> Available values for `AZURE_CLOUD_NAME`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`
295294
296295
### Option 2: Use Azure AD Workload Identity
297296
@@ -395,11 +394,10 @@ Before proceeding, ensure that you have installed [workload identity mutating ad
395394
AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID}
396395
AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
397396
AZURE_CLOUD_NAME=AzurePublicCloud
398-
AZURE_ENVIRONMENT=AzurePublicCloud
399397
EOF
400398
```
401399
402-
> Available values for `AZURE_CLOUD_NAME` and `AZURE_ENVIRONMENT`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`. `AZURE_ENVIRONMENT` is NOT required for `AzurePublicCloud`
400+
> Available values for `AZURE_CLOUD_NAME`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`
403401
404402
405403
### Option 3: Use storage account access key
@@ -418,11 +416,10 @@ _Note: this option is **not valid** if you are planning to take Azure snapshots
418416
cat << EOF > ./credentials-velero
419417
AZURE_STORAGE_ACCOUNT_ACCESS_KEY=${AZURE_STORAGE_ACCOUNT_ACCESS_KEY}
420418
AZURE_CLOUD_NAME=AzurePublicCloud
421-
AZURE_ENVIRONMENT=AzurePublicCloud
422419
EOF
423420
```
424421
425-
> Available values for `AZURE_CLOUD_NAME` and `AZURE_ENVIRONMENT`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`. `AZURE_ENVIRONMENT` is NOT required for `AzurePublicCloud`
422+
> Available values for `AZURE_CLOUD_NAME`: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`
426423
427424
## Install and start Velero
428425
@@ -491,7 +488,7 @@ After that update your velero BackupStorageLocation with the useAAD flag as show
491488
velero backup-location set default --provider azure --bucket $BLOB_CONTAINER --config useAAD="true",resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,storageAccount=$AZURE_STORAGE_ACCOUNT_ID[,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID]
492489
```
493490
494-
Limitation: Listing storage account access key is still needed for Restic/Kopia to work as expected on Azure. Tracking Issue: [#5984](https://github.com/vmware-tanzu/velero/issues/5984). The useAAD route won't accrue to them and users using kopia/restic should not remove the ListKeys permission from the velero identity.
491+
Limitation: Listing storage account access key is still needed for Restic to work as expected on Azure. The useAAD route won't accrue to it and users using Restic should not remove the ListKeys permission from the velero identity.
495492
496493
### If using storage account access key and no Azure snapshots:
497494

go.mod

+28-22
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,45 @@ module github.com/vmware-tanzu/velero-plugin-for-microsoft-azure
33
go 1.18
44

55
require (
6-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0
7-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0
6+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1
87
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0
9-
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0
10-
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.6.1
8+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.1.0
119
github.com/gofrs/uuid v4.3.1+incompatible
12-
github.com/joho/godotenv v1.4.0
1310
github.com/pkg/errors v0.9.1
14-
github.com/sirupsen/logrus v1.9.0
11+
github.com/sirupsen/logrus v1.9.3
1512
github.com/spf13/pflag v1.0.5
16-
github.com/stretchr/testify v1.8.2
17-
github.com/vmware-tanzu/velero v0.0.0-20230727074327-a6d79fc272a2
13+
github.com/stretchr/testify v1.8.4
14+
github.com/vmware-tanzu/velero v1.10.0
1815
k8s.io/api v0.26.0
1916
k8s.io/apimachinery v0.26.0
2017
sigs.k8s.io/azuredisk-csi-driver v1.26.0
2118
)
2219

20+
require (
21+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 // indirect
22+
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.3.0 // indirect
23+
github.com/joho/godotenv v1.4.0 // indirect
24+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
25+
)
26+
2327
require (
2428
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
25-
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
29+
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
2630
github.com/davecgh/go-spew v1.1.1 // indirect
2731
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
2832
github.com/fatih/color v1.15.0 // indirect
29-
github.com/go-logr/logr v1.2.3 // indirect
33+
github.com/go-logr/logr v1.2.4 // indirect
3034
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3135
github.com/go-openapi/jsonreference v0.20.1 // indirect
3236
github.com/go-openapi/swag v0.22.3 // indirect
3337
github.com/gobwas/glob v0.2.3 // indirect
3438
github.com/gogo/protobuf v1.3.2 // indirect
35-
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
39+
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
3640
github.com/golang/protobuf v1.5.3 // indirect
3741
github.com/google/gnostic v0.6.9 // indirect
3842
github.com/google/go-cmp v0.5.9 // indirect
3943
github.com/google/gofuzz v1.2.0 // indirect
40-
github.com/google/uuid v1.3.0 // indirect
44+
github.com/google/uuid v1.3.1 // indirect
4145
github.com/hashicorp/go-hclog v1.4.0 // indirect
4246
github.com/hashicorp/go-plugin v1.4.8 // indirect
4347
github.com/hashicorp/yamux v0.1.1 // indirect
@@ -47,7 +51,7 @@ require (
4751
github.com/kylelemons/godebug v1.1.0 // indirect
4852
github.com/mailru/easyjson v0.7.7 // indirect
4953
github.com/mattn/go-colorable v0.1.13 // indirect
50-
github.com/mattn/go-isatty v0.0.17 // indirect
54+
github.com/mattn/go-isatty v0.0.19 // indirect
5155
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
5256
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5357
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -58,17 +62,16 @@ require (
5862
github.com/spf13/afero v1.9.2 // indirect
5963
github.com/spf13/cobra v1.6.1 // indirect
6064
github.com/stretchr/objx v0.5.0 // indirect
61-
golang.org/x/crypto v0.8.0 // indirect
62-
golang.org/x/net v0.9.0 // indirect
63-
golang.org/x/oauth2 v0.7.0 // indirect
64-
golang.org/x/sys v0.7.0 // indirect
65-
golang.org/x/term v0.7.0 // indirect
66-
golang.org/x/text v0.9.0 // indirect
65+
golang.org/x/crypto v0.12.0 // indirect
66+
golang.org/x/net v0.14.0 // indirect
67+
golang.org/x/oauth2 v0.11.0 // indirect
68+
golang.org/x/sys v0.11.0 // indirect
69+
golang.org/x/term v0.11.0 // indirect
70+
golang.org/x/text v0.12.0 // indirect
6771
golang.org/x/time v0.3.0 // indirect
6872
google.golang.org/appengine v1.6.7 // indirect
69-
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
70-
google.golang.org/grpc v1.54.0 // indirect
71-
google.golang.org/protobuf v1.30.0 // indirect
73+
google.golang.org/grpc v1.57.0 // indirect
74+
google.golang.org/protobuf v1.31.0 // indirect
7275
gopkg.in/inf.v0 v0.9.1 // indirect
7376
gopkg.in/yaml.v2 v2.4.0 // indirect
7477
gopkg.in/yaml.v3 v3.0.1 // indirect
@@ -86,5 +89,8 @@ require (
8689
// * go list -modfile=go.mod -m -json -mod=mod all: k8s.io/[email protected]: invalid version: unknown revision v0.0.0
8790
replace (
8891
cloud.google.com/go => cloud.google.com/go v0.104.0
92+
// TODO update after the Velero PR merged
93+
github.com/vmware-tanzu/velero => github.com/ywk253100/velero v0.0.10
94+
// github.com/vmware-tanzu/velero => ../velero
8995
k8s.io/kubectl => k8s.io/kubectl v0.25.2
9096
)

0 commit comments

Comments
 (0)