Skip to content

Commit e27e293

Browse files
authored
fix: CRD loading: trim group suffix from CRD name (#3045)
* Fix CRD loading: trim group suffix from CRD name * gofmt
1 parent 18b2ada commit e27e293

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/dao/registry.go

+7
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,13 @@ func loadCRDs(f Factory, m ResourceMetas) {
424424
var meta metav1.APIResource
425425
meta.Kind = crd.Spec.Names.Kind
426426
meta.Group = crd.Spec.Group
427+
// Since CRD names are cluster scoped they need to be unique, however, it is allowed
428+
// to have the CRDs with the same names in different groups. Because of that, the
429+
// returned `crd.Name` values have the group as a suffix, for example
430+
// "ciliumnetworkpolicies.cilium.io".
431+
//
432+
// `Name` field of `meta/v1/APIResource` is supposed to be the plural name of the
433+
// resource, without the group. Because of that we need to trim the group suffix.
427434
meta.Name = strings.TrimSuffix(crd.Name, "."+meta.Group)
428435

429436
meta.SingularName = crd.Spec.Names.Singular

0 commit comments

Comments
 (0)