Merge pull request #4491 from ywk253100/220105_label

Initialize the labels field of `velero backup-location create` option
This commit is contained in:
Daniel Jiang
2022-01-10 23:03:09 +08:00
committed by GitHub
3 changed files with 13 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
Initialize the labels field of `velero backup-location create` option to avoid #4484
+1
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),
+11
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)
}