Merge pull request #4491 from ywk253100/220105_label
Initialize the labels field of `velero backup-location create` optionpull/4518/head
commit
a91483c55c
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue