Skip to content

Commit

Permalink
Fix a panic in GVRFromType for core objects
Browse files Browse the repository at this point in the history
  • Loading branch information
L3n41c committed Oct 25, 2024
1 parent 76c5888 commit 110f03d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ func GVRFromType(resourceName string, expectedType interface{}) *schema.GroupVer
return nil
}
apiVersion := expectedType.(*unstructured.Unstructured).Object["apiVersion"].(string)
expectedTypeSlice := strings.Split(apiVersion, "/")
g := expectedTypeSlice[0]
v := expectedTypeSlice[1]
if v == "" /* "" group (core) objects */ {
v = expectedTypeSlice[0]
g, v, found := strings.Cut(apiVersion, "/")
if !found {
g = "core"
v = apiVersion
}
r := resourceName
return &schema.GroupVersionResource{
Expand Down

0 comments on commit 110f03d

Please sign in to comment.