code-generator icon indicating copy to clipboard operation
code-generator copied to clipboard

applyconfiguration-gen does not respect the +groupName tag and uses the plain apiVersion

Open EraYaN opened this issue 2 years ago • 16 comments

So when using the Operator-SDK it generates a go file like groupversion_info.go in your main API package. This defines stuff like:

// Package v1alpha1 contains API Schema definitions for the cal.casa.eu v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=group.example.com
// +k8s:deepcopy-gen=package,register
// +k8s:openapi-gen=true
// +genclient
package v1alpha1

I added the genclient and k8s:openapi-gen=true, both of those are ignored by the way and need to be on every type.

But it also ignores the groupName so the applyconfiguration object ends up with

b.WithAPIVersion("v1alpha1")

While I expect

b.WithAPIVersion("group.example.com/v1alpha1")

Which I can fix with sed but I feel like it shouldn't really be a thing. I'm at a loss currently as to how to get it to first respect the tags on the package and then to actually include the groupName.

I got my generation code from here: https://github.com/cert-manager/cert-manager/pull/5383

EraYaN avatar Feb 15 '23 11:02 EraYaN