Skip to content

Commit 61f0f80

Browse files
committed
ensure crd gvr group suffix is trimmed
1 parent 19a5fb6 commit 61f0f80

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

internal/dao/registry.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,15 @@ func loadCRDs(f Factory, m ResourceMetas) {
411411
log.Err(err).Msg("boom")
412412
continue
413413
}
414+
gvr, version, ok := newGVRFromCRD(&crd)
415+
if !ok {
416+
continue
417+
}
414418

415-
if gvr, version, ok := newGVRFromCRD(&crd); ok {
416-
if meta, ok := m[gvr]; ok && version.Subresources != nil && version.Subresources.Scale != nil {
417-
if !slices.Contains(meta.Categories, scaleCat) {
418-
meta.Categories = append(meta.Categories, scaleCat)
419-
m[gvr] = meta
420-
}
419+
if meta, ok := m[gvr]; ok && version.Subresources != nil && version.Subresources.Scale != nil {
420+
if !slices.Contains(meta.Categories, scaleCat) {
421+
meta.Categories = append(meta.Categories, scaleCat)
422+
m[gvr] = meta
421423
}
422424
}
423425
}
@@ -427,13 +429,10 @@ func newGVRFromCRD(crd *apiext.CustomResourceDefinition) (client.GVR, apiext.Cus
427429
for _, v := range crd.Spec.Versions {
428430
if v.Served && !v.Deprecated {
429431
return client.NewGVRFromMeta(metav1.APIResource{
430-
Kind: crd.Spec.Names.Kind,
431-
Group: crd.Spec.Group,
432-
Name: crd.Spec.Names.Plural,
433-
Version: v.Name,
434-
ShortNames: crd.Spec.Names.ShortNames,
435-
SingularName: crd.Spec.Names.Plural,
436-
Namespaced: crd.Spec.Scope == apiext.NamespaceScoped,
432+
Kind: crd.Spec.Names.Kind,
433+
Group: crd.Spec.Group,
434+
Name: strings.TrimSuffix(crd.Name, "."+crd.Spec.Group),
435+
Version: v.Name,
437436
}), v, true
438437
}
439438
}

0 commit comments

Comments
 (0)