Skip to content

Commit 110f03d

Browse files
committed
Fix a panic in GVRFromType for core objects
1 parent 76c5888 commit 110f03d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pkg/util/utils.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ func GVRFromType(resourceName string, expectedType interface{}) *schema.GroupVer
143143
return nil
144144
}
145145
apiVersion := expectedType.(*unstructured.Unstructured).Object["apiVersion"].(string)
146-
expectedTypeSlice := strings.Split(apiVersion, "/")
147-
g := expectedTypeSlice[0]
148-
v := expectedTypeSlice[1]
149-
if v == "" /* "" group (core) objects */ {
150-
v = expectedTypeSlice[0]
146+
g, v, found := strings.Cut(apiVersion, "/")
147+
if !found {
148+
g = "core"
149+
v = apiVersion
151150
}
152151
r := resourceName
153152
return &schema.GroupVersionResource{

0 commit comments

Comments
 (0)