fix(controller): use ownerreferences without controller owner relation (#1095)

Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
This commit is contained in:
Oliver Bähler
2024-05-27 14:33:34 +02:00
committed by GitHub
parent 82995a3e66
commit 4afcfbbb27
7 changed files with 30 additions and 10 deletions

27
pkg/utils/reference.go Normal file
View File

@@ -0,0 +1,27 @@
// Copyright 2020-2023 Project Capsule Authors.
// SPDX-License-Identifier: Apache-2.0
package utils
import (
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
)
const (
ObjectReferenceTenantKind = "Tenant"
)
func IsTenantOwnerReference(or metav1.OwnerReference) bool {
parts := strings.Split(or.APIVersion, "/")
if len(parts) != 2 {
return false
}
group := parts[0]
return group == capsulev1beta2.GroupVersion.Group && or.Kind == ObjectReferenceTenantKind
}