Skip to content

Commit

Permalink
feat(snapshots): support for orLabelSelectors (#5039)
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh authored Dec 10, 2024
1 parent 53df28f commit 7b51555
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/kotsadmsnapshot/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ func mergeAppBackupSpec(backup *velerov1.Backup, appMeta appInstanceBackupMetada
// excluded namespaces
backup.Spec.ExcludedNamespaces = append(backup.Spec.ExcludedNamespaces, kotskindsBackup.Spec.ExcludedNamespaces...)

// or label selectors
backup.Spec.OrLabelSelectors = append(backup.Spec.OrLabelSelectors, kotskindsBackup.Spec.OrLabelSelectors...)

// annotations
if len(kotskindsBackup.ObjectMeta.Annotations) > 0 {
if backup.Annotations == nil {
Expand Down
28 changes: 28 additions & 0 deletions pkg/kotsadmsnapshot/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,13 @@ func Test_mergeAppBackupSpec(t *testing.T) {
Spec: velerov1.BackupSpec{
IncludedNamespaces: []string{"include-namespace-1", "include-namespace-2", "template-isairgap-{{repl IsAirgap }}"},
ExcludedNamespaces: []string{"exclude-namespace-1", "exclude-namespace-2"},
OrLabelSelectors: []*metav1.LabelSelector{
{
MatchLabels: map[string]string{
"app": "app-1",
},
},
},
OrderedResources: map[string]string{
"resource-1": "true",
"resource-2": "false",
Expand Down Expand Up @@ -1299,6 +1306,13 @@ func Test_mergeAppBackupSpec(t *testing.T) {
StorageLocation: "default",
IncludedNamespaces: []string{"kotsadm", "another-namespace-1", "another-namespace-2", "include-namespace-1", "include-namespace-2", "template-isairgap-true"},
ExcludedNamespaces: []string{"exclude-namespace-1", "exclude-namespace-2"},
OrLabelSelectors: []*metav1.LabelSelector{
{
MatchLabels: map[string]string{
"app": "app-1",
},
},
},
OrderedResources: map[string]string{
"resource-1": "true",
"resource-2": "false",
Expand Down Expand Up @@ -1431,6 +1445,13 @@ func Test_mergeAppBackupSpec(t *testing.T) {
Spec: velerov1.BackupSpec{
IncludedNamespaces: []string{"include-namespace-1", "include-namespace-2", "template-isairgap-{{repl IsAirgap }}"},
ExcludedNamespaces: []string{"exclude-namespace-1", "exclude-namespace-2"},
OrLabelSelectors: []*metav1.LabelSelector{
{
MatchLabels: map[string]string{
"app": "app-1",
},
},
},
OrderedResources: map[string]string{
"resource-1": "true",
"resource-2": "false",
Expand Down Expand Up @@ -1471,6 +1492,13 @@ func Test_mergeAppBackupSpec(t *testing.T) {
StorageLocation: "default",
IncludedNamespaces: []string{"kotsadm", "another-namespace-1", "another-namespace-2", "include-namespace-1", "include-namespace-2", "template-isairgap-true"},
ExcludedNamespaces: []string{"exclude-namespace-1", "exclude-namespace-2"},
OrLabelSelectors: []*metav1.LabelSelector{
{
MatchLabels: map[string]string{
"app": "app-1",
},
},
},
OrderedResources: map[string]string{
"resource-1": "true",
"resource-2": "false",
Expand Down

0 comments on commit 7b51555

Please sign in to comment.