Skip to content

Commit

Permalink
fix ownerref handling
Browse files Browse the repository at this point in the history
  • Loading branch information
stlaz committed Mar 26, 2024
1 parent 28db3f8 commit 0794bb1
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions pkg/console/subresource/util/util.go
Expand Up @@ -74,30 +74,25 @@ func LogYaml(obj runtime.Object) {

// objects can have more than one ownerRef, potentially
func AddOwnerRef(obj metav1.Object, ownerRef *metav1.OwnerReference) {
// TODO: find the library-go equivalent of this and replace
// currently errs out with something like:
// failed with: ConfigMap "console-config" is invalid: [metadata.ownerReferences.apiVersion: Invalid value: "": version must not be empty, metadata.ownerReferences.kind: Invalid value: "": kind must not be empty]
//if obj != nil {
// if ownerRef != nil {
// obj.SetOwnerReferences(append(obj.GetOwnerReferences(), *ownerRef))
// }
//}
if obj != nil && ownerRef != nil {
obj.SetOwnerReferences(append(obj.GetOwnerReferences(), *ownerRef))
}
}

// func RemoveOwnerRef
func OwnerRefFrom(cr *operatorv1.Console) *metav1.OwnerReference {
if cr == nil {
return nil
}

if cr != nil {
truthy := true
return &metav1.OwnerReference{
APIVersion: cr.APIVersion,
Kind: cr.Kind,
Name: cr.Name,
UID: cr.UID,
Controller: &truthy,
}
truthy := true
return &metav1.OwnerReference{
APIVersion: "operator.openshift.io/v1",
Kind: "Console",
Name: cr.Name,
UID: cr.UID,
Controller: &truthy,
}
return nil
}

// borrowed from library-go
Expand Down

0 comments on commit 0794bb1

Please sign in to comment.