Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code-generator]: add register-gen to helper script kube_codegen.sh #124219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

caozhuozi
Copy link

What type of PR is this?

/kind feature

What this PR does / why we need it:

Register code is just as common as deepcopy, client, informer, defaulter (and so on) in CRD development.
However, the helper script kube_codegen.sh within the code-generator does not include a function for registration.
This pull request attempts to add it.

Which issue(s) this PR fixes:

Fixes kubernetes/code-generator#169

Special notes for your reviewer:

I am aware that some subsequent changes may also be necessary, such as replacing the manually created register file (e.g., ·examples/crd/apis/example/v1/register.go·) with the generated register version.

But I need your confirmation on this matter. Additionally, if any other subsequent changes need to be made, please also let me know.

Does this PR introduce a user-facing change?

the `kube_codegen.sh` helper script of `code-generator` added `kube::codegen::gen_register` function for generating register code.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 7, 2024
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.30 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.30.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Sun Apr 7 13:42:56 UTC 2024.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 7, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @caozhuozi!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 7, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @caozhuozi. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 7, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caozhuozi
Once this PR has been reviewed and has the lgtm label, please assign sttts for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/code-generation sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 7, 2024
@alexzielenski
Copy link
Contributor

/cc @jpbetz
for your take on whether this is advisable
/triage accepted

@k8s-ci-robot k8s-ci-robot requested a review from jpbetz April 9, 2024 20:06
@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 9, 2024
@jpbetz
Copy link
Contributor

jpbetz commented Apr 12, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 12, 2024
@jpbetz
Copy link
Contributor

jpbetz commented Apr 12, 2024

Thanks for the contribution!

I haven't put much thought into what the edge cases for registration are, but we might be able to tease it out.

I think we should merge the generation utilities in the same PR that makes use of the generators. This could get quite involved and result in a much larger PR. The basic shape I'd expect would include things like:

  • Both a generation and validation capability, like present with the other generators, integrated into the appropriate entry points for build and pre-submit
  • All the generated code split cleanly into generated files
  • All the changes to the code as a result of switching to the generator in this PR so we can see what exact changes it has made
  • Handling of any edge cases or special cases that exist in the codebase, and generation in sample projects and the various apiservers.

There are probably a lot of other details, hopefully that starts to summarize the path we'd need to go down to fully incorporate this into the codebase.

@caozhuozi
Copy link
Author

Thank you for your comment. I will digest it one by one and make changes accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there a specific reason why we exclude register-gen in kube_codegen.sh?
4 participants