Skip to content

Commit

Permalink
Merge pull request #213 from xuzhenglun/fix-211
Browse files Browse the repository at this point in the history
check object scope before fetching
  • Loading branch information
k8s-ci-robot authored Apr 5, 2022
2 parents 63888ac + 9c89b9f commit 8d26bce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/patterns/declarative/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,11 @@ func GetObjectFromCluster(obj *manifest.Object, r *Reconciler) (*unstructured.Un
if err != nil {
return nil, fmt.Errorf("unable to get mapping for resource %v: %w", gvk, err)
}
ns := obj.GetNamespace()
name := obj.GetName()

ns, name := "", obj.GetName()
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
ns = obj.GetNamespace()
}
unstruct, err := r.dynamicClient.Resource(mapping.Resource).Namespace(ns).Get(context.Background(), name, getOptions)
if err != nil {
return nil, fmt.Errorf("unable to get object: %w", err)
Expand Down

0 comments on commit 8d26bce

Please sign in to comment.