layer1: centralize managed namespace labels step 13
This commit is contained in:
@@ -17,8 +17,18 @@ const (
|
||||
ENV_BUILDER_NAMESPACE string = "FISSION_BUILDER_NAMESPACE"
|
||||
ENV_DEFAULT_NAMESPACE string = "FISSION_DEFAULT_NAMESPACE"
|
||||
ENV_ADDITIONAL_NAMESPACE string = "FISSION_RESOURCE_NAMESPACES"
|
||||
ManagedNamespaceLabelKey string = "fission.io/managed"
|
||||
ManagedNamespaceLabelValue string = "true"
|
||||
)
|
||||
|
||||
func ManagedNamespaceLabelSelector() string {
|
||||
return ManagedNamespaceLabelKey + "=" + ManagedNamespaceLabelValue
|
||||
}
|
||||
|
||||
func IsManagedNamespace(labels map[string]string) bool {
|
||||
return labels[ManagedNamespaceLabelKey] == ManagedNamespaceLabelValue
|
||||
}
|
||||
|
||||
type (
|
||||
NamespaceResolver struct {
|
||||
mu sync.RWMutex // protects FissionResourceNS
|
||||
|
||||
@@ -216,6 +216,18 @@ func TestNamespaceResolver(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("managed namespace label helpers", func(t *testing.T) {
|
||||
if ManagedNamespaceLabelSelector() != "fission.io/managed=true" {
|
||||
t.Fatalf("unexpected managed namespace selector: %s", ManagedNamespaceLabelSelector())
|
||||
}
|
||||
if !IsManagedNamespace(map[string]string{ManagedNamespaceLabelKey: ManagedNamespaceLabelValue}) {
|
||||
t.Fatalf("expected managed namespace to be detected")
|
||||
}
|
||||
if IsManagedNamespace(map[string]string{ManagedNamespaceLabelKey: "false"}) {
|
||||
t.Fatalf("expected non-managed namespace to be rejected")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("getNamespace", func(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user