From 110f03d7331faddbd1950fb2a5cd7f713b775704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Thu, 24 Oct 2024 18:39:17 +0200 Subject: [PATCH] Fix a panic in GVRFromType for core objects --- pkg/util/utils.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 14b108f37e..837a0fd564 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -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{