Skip to content

Commit

Permalink
Use discovery mapper first resource result when available
Browse files Browse the repository at this point in the history
  • Loading branch information
talsabagport committed Dec 21, 2022
1 parent 798ad86 commit e82919c
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 e82919c

Please sign in to comment.