Skip to content

Commit

Permalink
add label selector for created-by: nats-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Dec 29, 2023
1 parent 9abf991 commit e8aea48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ const (
KeyPartOf = "app.kubernetes.io/part-of"
KeyDashboard = "kyma-project.io/dashboard"

// Kubernetes label keys used by nats-manager.
// Kubernetes label values used by nats-manager.
ValueNATS = "nats"
ValueNATSManager = "nats-manager"
)

// SelectorInstanceNATS returns a labelselector for instance ("app.kubernetes.io/instance") as usesd
// SelectorInstanceNATS returns a labelselector for instance ("app.kubernetes.io/instance") as used
// by the nats-manager.
func SelectorInstanceNATS() labels.Selector {
return labels.SelectorFromSet(map[string]string{KeyInstance: ValueNATSManager})
}

// SelectorCreatedByNATS returns a labelselector for created-by ("app.kubernetes.io/created-by") as used
// by the nats-manager.
func SelectorCreatedByNATS() labels.Selector {
return labels.SelectorFromSet(map[string]string{KeyCreatedBy: ValueNATSManager})
}
13 changes: 13 additions & 0 deletions internal/label/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@ func TestSelectorInstanceNATS(t *testing.T) {
t.Errorf("Expected %v, but got %v", wantedSelector, actualSelector)
}
}

func TestSelectorCreatedByNATS(t *testing.T) {
// arrange
wantedSelector := labels.SelectorFromSet(map[string]string{"app.kubernetes.io/created-by": "nats-manager"})

// act
actualSelector := label.SelectorCreatedByNATS()

// assert
if !reflect.DeepEqual(wantedSelector, actualSelector) {
t.Errorf("Expected %v, but got %v", wantedSelector, actualSelector)
}
}

0 comments on commit e8aea48

Please sign in to comment.