Skip to content

Commit

Permalink
Merge pull request #76 from kubescape/handle-crds
Browse files Browse the repository at this point in the history
Ignore forbidden resources
  • Loading branch information
David Wertenteil authored Oct 20, 2023
2 parents ae69612 + 540eac1 commit 42ff7b5
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 42ff7b5

Please sign in to comment.