func OwnerReferencesPresent(
	cr KubeDirectorObject,
	currentRefs []metav1.OwnerReference,
) bool {
	desiredRef := &(OwnerReferences(cr)[0])
	for _, ref := range currentRefs {
		if (ref.APIVersion == desiredRef.APIVersion) &&
			(ref.Kind == desiredRef.Kind) &&
			(ref.Name == desiredRef.Name) &&
			(ref.UID == desiredRef.UID) &&
			(ref.Controller != nil) &&
			(*ref.Controller == true) {
			return true
		}
	}
	return false
}
OwnerReferencesPresent determines whether the desired references (from
the ownerReferences func) are present in the CR.
package shared
import (
	"fmt"
	"os"
	kdv1 "github.com/bluek8s/kubedirector/pkg/apis/kubedirector/v1beta1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
)
func StrPtr(s string) *string {
	return &s
}
func StringInList(
	test string,
	list []string,
) bool {
	for _, s := range list {
		if s == test {
			return true
		}
	}
	return false
}
func ListIsUnique(
	list []string,
) bool {
	seen := make(map[string]bool)
	for _, s := range list {
		if _, ok := seen[s]; ok {
			return false
		}
		seen[s] = true
	}
	return true
}
func GetKubeDirectorNamespace() (string, error) {
	ns, found := os.LookupEnv(KubeDirectorNamespaceEnvVar)
	if !found {
		return "", fmt.Errorf("%s must be set", KubeDirectorNamespaceEnvVar)
	}
	return ns, nil
}
func OwnerReferences(
	cr KubeDirectorObject,
) []metav1.OwnerReference {
	return []metav1.OwnerReference{
		*metav1.NewControllerRef(cr, schema.GroupVersionKind{
			Group:   kdv1.SchemeGroupVersion.Group,
			Version: kdv1.SchemeGroupVersion.Version,
			Kind:    cr.GetObjectKind().GroupVersionKind().Kind,
		}),
	}
}