diff --git a/internal/label/label.go b/internal/label/label.go index 51499768..c3140965 100644 --- a/internal/label/label.go +++ b/internal/label/label.go @@ -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}) +} diff --git a/internal/label/label_test.go b/internal/label/label_test.go index 4a238464..47294725 100644 --- a/internal/label/label_test.go +++ b/internal/label/label_test.go @@ -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) + } +}