Skip to content

Commit a65c60b

Browse files
committed
GetObjectFromCluster should preserve error chain
Otherwise apierrors.IsNotFound does not work correctly, and we spam a misleading errors message.
1 parent f77bb49 commit a65c60b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/patterns/declarative/reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,13 @@ func GetObjectFromCluster(obj *manifest.Object, r *Reconciler) (*unstructured.
571571

572572
mapping, err := r.restMapper.RESTMapping(obj.GroupKind(), gvk.Version)
573573
if err != nil {
574-
return nil, fmt.Errorf("unable to get resource: %v", err)
574+
return nil, fmt.Errorf("unable to get mapping for resource: %w", err)
575575
}
576576
ns := obj.UnstructuredObject().GetNamespace()
577577
unstruct, err := r.dynamicClient.Resource(mapping.Resource).Namespace(ns).Get(context.Background(),
578578
obj.Name, getOptions)
579579
if err != nil {
580-
return nil, fmt.Errorf("unable to get mapping for resource: %v", err)
580+
return nil, fmt.Errorf("unable to get object: %w", err)
581581
}
582582
return unstruct, nil
583583
}

0 commit comments

Comments
 (0)