generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0aa71fa
commit b6bbe49
Showing
4 changed files
with
97 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package labels | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/labels" | ||
) | ||
|
||
const ( | ||
// Kubernetes label keys used by nats-manager. | ||
KeyComponent = "app.kubernetes.io/component" | ||
KeyCreatedBy = "app.kubernetes.io/created-by" | ||
KeyInstance = "app.kubernetes.io/instance" | ||
KeyManagedBy = "app.kubernetes.io/managed-by" | ||
KeyName = "app.kubernetes.io/name" | ||
KeyPartOf = "app.kubernetes.io/part-of" | ||
KeyDashboard = "kyma-project.io/dashboard" | ||
|
||
// Kubernetes label values used by nats-manager. | ||
ValueNATS = "nats" | ||
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}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package labels | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"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"}) | ||
|
||
// act | ||
actualSelector := SelectorManagedByNATS() | ||
|
||
// assert | ||
if !reflect.DeepEqual(wantedSelector, actualSelector) { | ||
t.Errorf("Expected %v, but got %v", wantedSelector, actualSelector) | ||
} | ||
} |