Skip to content

Commit

Permalink
fix(labelsMatchExpressions): reintroduce support for instanceSelector…
Browse files Browse the repository at this point in the history
…: {}
  • Loading branch information
weisdd committed May 16, 2024
1 parent f44b828 commit ea373ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion controllers/controller_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ func GetMatchingInstances(ctx context.Context, k8sClient client.Client, labelSel
}

func labelsSatisfyMatchExpressions(labels map[string]string, matchExpressions []metav1.LabelSelectorRequirement) bool {
// To preserve support for scenario with instanceSelector: {}
if len(labels) == 0 {
return false
return true
}

if len(matchExpressions) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions controllers/controller_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestLabelsSatisfyMatchExpressions(t *testing.T) {
name: "No labels and no expressions",
labels: map[string]string{},
matchExpressions: []metav1.LabelSelectorRequirement{},
want: false,
want: true,
},
{
name: "No labels",
Expand All @@ -45,7 +45,7 @@ func TestLabelsSatisfyMatchExpressions(t *testing.T) {
Key: "dashboards",
},
},
want: false,
want: true,
},
{
name: "No matchExpressions",
Expand Down

0 comments on commit ea373ea

Please sign in to comment.