Merge pull request #4491 from ywk253100/220105_label

Initialize the labels field of `velero backup-location create` option
pull/4518/head
Daniel Jiang 2022-01-10 23:03:09 +08:00 committed by GitHub
commit a91483c55c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1 @@
Initialize the labels field of `velero backup-location create` option to avoid #4484

View File

@ -78,6 +78,7 @@ func NewCreateOptions() *CreateOptions {
return &CreateOptions{
Credential: flag.NewMap(),
Config: flag.NewMap(),
Labels: flag.NewMap(),
AccessMode: flag.NewEnum(
string(velerov1api.BackupStorageLocationAccessModeReadWrite),
string(velerov1api.BackupStorageLocationAccessModeReadWrite),

View File

@ -76,3 +76,14 @@ func TestBuildBackupStorageLocationSetsCredential(t *testing.T) {
Key: "key-from-secret",
}, bsl.Spec.Credential)
}
func TestBuildBackupStorageLocationSetsLabels(t *testing.T) {
o := NewCreateOptions()
err := o.Labels.Set("key=value")
assert.NoError(t, err)
bsl, err := o.BuildBackupStorageLocation("velero-test-ns", false, false)
assert.NoError(t, err)
assert.Equal(t, map[string]string{"key": "value"}, bsl.Labels)
}