Skip to content

Commit

Permalink
Use namespace of the reference on Get
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Oct 31, 2024
1 parent e75b4e7 commit 3a8f8ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/external/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3a8f8ac

Please sign in to comment.