Skip to content

Commit

Permalink
Fix CRD loading: trim group suffix from CRD name
Browse files Browse the repository at this point in the history
  • Loading branch information
ivant committed Dec 29, 2024
1 parent 420a533 commit 424873f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/dao/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,15 @@ func loadCRDs(f Factory, m ResourceMetas) {
var meta metav1.APIResource
meta.Kind = crd.Spec.Names.Kind
meta.Group = crd.Spec.Group
meta.Name = crd.Name
// Since CRD names are cluster scoped they need to be unique, however, it is allowed
// to have the CRDs with the same names in different groups. Because of that, the
// returned `crd.Name` values have the group as a suffix, for example
// "ciliumnetworkpolicies.cilium.io".
//
// `Name` field of `meta/v1/APIResource` is supposed to be the plural name of the
// resource, without the group. Because of that we need to trim the group suffix.
meta.Name = strings.TrimSuffix(crd.Name, "." + meta.Group)

meta.SingularName = crd.Spec.Names.Singular
meta.ShortNames = crd.Spec.Names.ShortNames
meta.Namespaced = crd.Spec.Scope == apiext.NamespaceScoped
Expand Down

0 comments on commit 424873f

Please sign in to comment.