mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-04 15:16:58 +00:00
Merge pull request #4491 from ywk253100/220105_label
Initialize the labels field of `velero backup-location create` option
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Initialize the labels field of `velero backup-location create` option to avoid #4484
|
||||
@@ -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),
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user