Skip to content

Commit

Permalink
set gvk in GetTypedOwnerByRef
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Jan 9, 2024
1 parent 24004bf commit aa29d37
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bootstrap/util/configowner.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func GetOwnerByRef(ctx context.Context, c client.Client, ref *corev1.ObjectRefer
// GetTypedOwnerByRef finds and returns the owner by looking at the object
// reference. The implementation ensures a typed client is used, so the objects are read from the cache.
func GetTypedOwnerByRef(ctx context.Context, c client.Client, ref *corev1.ObjectReference) (*ConfigOwner, error) {
obj, err := c.Scheme().New(ref.GroupVersionKind())
objGVK := ref.GroupVersionKind()
obj, err := c.Scheme().New(objGVK)
if err != nil {
return nil, errors.Wrapf(err, "failed to construct object of type %s", ref.GroupVersionKind())
}
Expand All @@ -209,6 +210,7 @@ func GetTypedOwnerByRef(ctx context.Context, c client.Client, ref *corev1.Object
}
u := unstructured.Unstructured{}
u.SetUnstructuredContent(content)
u.SetGroupVersionKind(objGVK)

return &ConfigOwner{&u}, nil
}

0 comments on commit aa29d37

Please sign in to comment.