Skip to content

Commit

Permalink
clean up labels
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Jan 3, 2024
1 parent fda7059 commit 5b96aae
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 40 deletions.
2 changes: 1 addition & 1 deletion internal/controller/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_applySelectors(t *testing.T) {
selector := cache.ByObject{
Label: labels.SelectorFromSet(
map[string]string{
natslabels.KeyCreatedBy: natslabels.ValueNATSManager,
natslabels.KeyManagedBy: natslabels.ValueNATSManager,
},
),
}
Expand Down
14 changes: 1 addition & 13 deletions pkg/labels/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,8 @@ const (
ValueNATSManager = "nats-manager"
)

// 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})
}

// SelectorCreatedByNATS returns a labelselector for created-by ("app.kubernetes.io/created-by") as used
// by the nats-manager.
func SelectorManagedByNATS() labels.Selector {
return labels.SelectorFromSet(map[string]string{KeyCreatedBy: ValueNATSManager})
return labels.SelectorFromSet(map[string]string{KeyManagedBy: ValueNATSManager})
}
26 changes: 0 additions & 26 deletions pkg/labels/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,6 @@ import (
"k8s.io/apimachinery/pkg/labels"
)

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

// act
actualSelector := SelectorInstanceNATS()

// assert
if !reflect.DeepEqual(wantedSelector, actualSelector) {
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 := SelectorCreatedByNATS()

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

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

0 comments on commit 5b96aae

Please sign in to comment.