diff --git a/controllers/external/util.go b/controllers/external/util.go index 4efdb9c133f2..505f7a2f5987 100644 --- a/controllers/external/util.go +++ b/controllers/external/util.go @@ -39,9 +39,9 @@ func Get(ctx context.Context, c client.Reader, ref *corev1.ObjectReference, name obj.SetAPIVersion(ref.APIVersion) obj.SetKind(ref.Kind) obj.SetName(ref.Name) - key := client.ObjectKey{Name: obj.GetName(), Namespace: namespace} - if err := c.Get(ctx, key, obj); err != nil { - return nil, errors.Wrapf(err, "failed to retrieve %s external object %q/%q", obj.GetKind(), key.Namespace, key.Name) + obj.SetNamespace(ref.Namespace) + if err := c.Get(ctx, client.ObjectKeyFromObject(obj), obj); err != nil { + return nil, errors.Wrapf(err, "failed to retrieve %s external object %q/%q", obj.GetKind(), ref.Namespace, ref.Name) } return obj, nil }