Skip to content

Commit

Permalink
chore: rename labelsMatchExpressions to labelsSatisfyMatchExpressions
Browse files Browse the repository at this point in the history
  • Loading branch information
weisdd committed May 5, 2024
1 parent 5997012 commit 4fa7dc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions controllers/controller_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func GetMatchingInstances(ctx context.Context, k8sClient client.Client, labelSel
var selectedList v1beta1.GrafanaList

for _, instance := range list.Items {
selected := labelsMatchExpressions(instance.Labels, labelSelector.MatchExpressions)
selected := labelsSatisfyMatchExpressions(instance.Labels, labelSelector.MatchExpressions)
if selected {
selectedList.Items = append(selectedList.Items, instance)
}
Expand All @@ -48,7 +48,7 @@ func GetMatchingInstances(ctx context.Context, k8sClient client.Client, labelSel
return selectedList, err
}

func labelsMatchExpressions(labels map[string]string, matchExpressions []metav1.LabelSelectorRequirement) bool {
func labelsSatisfyMatchExpressions(labels map[string]string, matchExpressions []metav1.LabelSelectorRequirement) bool {
if len(labels) == 0 {
return false
}
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 @@ -23,7 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestLabelsMatchExpressions(t *testing.T) {
func TestLabelsSatisfyMatchExpressions(t *testing.T) {
tests := []struct {
name string
labels map[string]string
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestLabelsMatchExpressions(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := labelsMatchExpressions(tt.labels, tt.matchExpressions)
got := labelsSatisfyMatchExpressions(tt.labels, tt.matchExpressions)
assert.Equal(t, tt.want, got)
})
}
Expand Down

0 comments on commit 4fa7dc5

Please sign in to comment.