mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-19 12:36:39 +00:00
* chore: add nwa Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: update helm-schema version Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: update helm-schema version Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> --------- Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
// Copyright 2020-2025 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
networkingv1 "k8s.io/api/networking/v1"
|
|
rbacv1 "k8s.io/api/rbac/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
"github.com/projectcapsule/capsule/api/v1beta1"
|
|
"github.com/projectcapsule/capsule/api/v1beta2"
|
|
)
|
|
|
|
const (
|
|
CordonedLabel = "projectcapsule.dev/cordoned"
|
|
)
|
|
|
|
func GetTypeLabel(t runtime.Object) (label string, err error) {
|
|
switch v := t.(type) {
|
|
case *v1beta1.Tenant, *v1beta2.Tenant:
|
|
return "capsule.clastix.io/tenant", nil
|
|
case *v1beta2.ResourcePool:
|
|
return "projectcapsule.dev/pool", nil
|
|
case *corev1.LimitRange:
|
|
return "capsule.clastix.io/limit-range", nil
|
|
case *networkingv1.NetworkPolicy:
|
|
return "capsule.clastix.io/network-policy", nil
|
|
case *corev1.ResourceQuota:
|
|
return "capsule.clastix.io/resource-quota", nil
|
|
case *rbacv1.RoleBinding:
|
|
return "capsule.clastix.io/role-binding", nil
|
|
default:
|
|
err = fmt.Errorf("type %T is not mapped as Capsule label recognized", v)
|
|
}
|
|
|
|
return
|
|
}
|