Skip to content

Commit

Permalink
ignore forbidden resources
Browse files Browse the repository at this point in the history
Signed-off-by: David Wertenteil <[email protected]>
  • Loading branch information
David Wertenteil committed Oct 20, 2023
1 parent ae69612 commit 540eac1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions k8sinterface/k8sdiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
)

const (
ValueNotFound = -1
ResourceNotFoundErr = "resource not found"
ValueNotFound = -1
ResourceNotFoundErr = "resource not found"
ResourceForbiddenErr = "is forbidden"
)

// ResourceGroupMapping mapping of all supported Kubernetes cluster resources to apiVersion
Expand Down
2 changes: 1 addition & 1 deletion k8sinterface/k8sdynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (k8sAPI *KubernetesApi) CalculateWorkloadParentRecursive(workload IWorkload

parentWorkload, err := k8sAPI.GetWorkload(workload.GetNamespace(), ownerKind, ownerName)
if err != nil {
if strings.Contains(err.Error(), ResourceNotFoundErr) { // if parent is CRD
if strings.Contains(err.Error(), ResourceNotFoundErr) || strings.Contains(err.Error(), ResourceForbiddenErr) { // if parent is CRD
return workload.GetKind(), workload.GetName(), nil // parent found
}
return workload.GetKind(), workload.GetName(), err
Expand Down

0 comments on commit 540eac1

Please sign in to comment.