diff --git a/bootstrap/util/configowner.go b/bootstrap/util/configowner.go index f015443feda9..1729629bc81e 100644 --- a/bootstrap/util/configowner.go +++ b/bootstrap/util/configowner.go @@ -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()) } @@ -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 }