Skip to content

Commit

Permalink
Merge pull request #5 from port-labs/PORT-2282-add-crd-support-to-the…
Browse files Browse the repository at this point in the history
…-k-8-s-exporter

Use discovery mapper first resource result when available
  • Loading branch information
talsabagport authored Dec 21, 2022
2 parents 798ad86 + e82919c commit 2ada113
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/k8s/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ func GetGVRFromResource(discoveryMapper *restmapper.DeferredDiscoveryRESTMapper,
gvr = schema.GroupVersionResource{Group: "", Version: s[0], Resource: s[1]}
}

if _, err := discoveryMapper.ResourcesFor(gvr); err != nil {
gvrs, err := discoveryMapper.ResourcesFor(gvr)
if err != nil {
return schema.GroupVersionResource{}, err
}
if len(gvrs) == 0 {
return gvr, nil
}

return gvr, nil
return gvrs[0], nil
}

0 comments on commit 2ada113

Please sign in to comment.