controller-tools
controller-tools copied to clipboard
applyconfiguration generator uses a different variable name
In #818 support for generating ApplyConfiguration was added via the applyconfiguration generator. However, it uses different variable name (SchemeGroupVersion) than the name generated by kubebuilder (GroupVersion). This results in a build failures out of the box.
# sigs.k8s.io/controller-tools/pkg/applyconfiguration/testdata/cronjob/api/v1/applyconfiguration
api/v1/applyconfiguration/utils.go:19:10: undefined: v1.SchemeGroupVersion
The variable name from kubebuilder is set in the groupversion_info.go template:
https://github.com/kubernetes-sigs/kubebuilder/blob/9932c89b631bb03413afe858c736613c66e07882/pkg/plugins/golang/v4/scaffolds/internal/templates/api/group.go#L68-L69
The variable name in the upstream applyconfiguration-gen is set in the GenerateType implementation:
https://github.com/kubernetes/code-generator/blob/2a635fa63960c0d6fd2461819f261ed8b9115f57/cmd/applyconfiguration-gen/generators/util.go#L127-L130
The fix for users is simple (SchemeGroupVersion = GroupVersion) but it would be nice if the files generated here work out of the box with those from kubebuilder.
We have no influence over the code in code-generator that we are relying on here. However, we do have influence over the loaded universe. It's possible that we could detect whether the required SchemeGroupVersion exists, and, should it not exist, mock it up from the GroupVersion.
That could be a bit fragile, so we would want to also check that the types match our expectations, but at least if we put this check in earlier, we could also add a warning if we aren't able to detect the schema.GroupVersion that we require, and bail out of the generation earlier
Edit: We are already doing something similar to make sure the correct markers for +genclient are on the types we expect.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle stale - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle rotten - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
/remove-lifecycle rotten
/label help-wanted
@JoelSpeed: The label(s) /label help-wanted cannot be applied. These labels are supported: api-review, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, team/katacoda, refactor, ci-short, ci-extended, ci-full. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?
In response to this:
/label help-wanted
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
/help
@sbueringer: This request has been marked as needing help from a contributor.
Guidelines
Please ensure that the issue body includes answers to the following questions:
- Why are we solving this issue?
- To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
- How can the assignee reach out to you for help?
For more details on the requirements of such an issue, please see here and ensure that they are met.
If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.
In response to this:
/help
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.