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: Go native codegen for gen-helpers #122236

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

Conversation

cardil
Copy link

@cardil cardil commented Dec 8, 2023

What type of PR is this?

/kind feature
/kind cleanup

What this PR does / why we need it:

This PR rewrites the shell code from kube_codegen.sh into a Go code with both executable, and packages which may be used downstream. I purposely limited the scope for now to just kube::codegen::gen_helpers. The follow-up PRs are, of course, expected.

The reasons for this are explained in the connected issue: kubernetes/code-generator#163.

Which issue(s) this PR fixes:

Fixes kubernetes/code-generator#163 (partially)

Special notes for your reviewer:

This is the first PR for this issue. Expect PRs for other shell functions: kube::codegen::gen_openapi and kube::codegen::gen_client.

The idea is not to change the logic of the generator, or the flags, and to keep 100% compatibility.

Does this PR introduce a user-facing change?

The Kubernetes code-generator has now the new Go-native entrypoint wrapper. This allows for easier management in downstream projects, and usage with Go' `go run k8s.io/code-generator` command, even without the Kubernetes sources.

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 8, 2023
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.29 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.29.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Fri Dec 8 10:14:44 UTC 2023.

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 8, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @cardil!

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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 8, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @cardil. 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 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 Dec 8, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cardil
Once this PR has been reviewed and has the lgtm label, please assign deads2k 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

@upodroid
Copy link
Member

upodroid commented Dec 8, 2023

/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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 8, 2023
@cardil cardil force-pushed the feature/go-native-codegen branch 2 times, most recently from 87a6908 to c4ce601 Compare December 11, 2023 17:31
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Dec 11, 2023
@cardil cardil force-pushed the feature/go-native-codegen branch 2 times, most recently from de65f5f to 63c80bb Compare December 11, 2023 18:48
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2023
@Jefftree
Copy link
Member

/cc @thockin
/triage accepted

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 12, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 18, 2024
@cardil cardil force-pushed the feature/go-native-codegen branch 2 times, most recently from 644a5be to 1cd3950 Compare January 19, 2024 18:47
@cardil
Copy link
Author

cardil commented Jan 19, 2024

Hey @thockin! Today, I figured out that my changes here, and yours from master...thockin:kubernetes:go-workspaces-except-gengo are mostly orthogonal, and shouldn't block each other.

I'm focusing here, only, on the refactoring of the gen_* shell functions from the https://github.com/kubernetes/kubernetes/blob/9bd0ef5f173de3cc2d1d629a4aee499d53690aee/staging/src/k8s.io/code-generator/kube_codegen.sh file. And, you are changing the whole setup of building and testing the whole project. That's great, and as I said, I can help you with that, if you can divide the work into maintainable chunks, and act as mini-project leader.

However, I think your work shouldn't block my changes.

Today, I've checked, how much effort would it bring, for you, the merging of this PR. See the conflicts here: https://github.com/thockin/kubernetes/pull/14/conflicts. As far as I can see, the conflicts aren't very problematic, and resolving them should be straightforward. Even more, I can file a second, smaller PR, as already discussed, that will refactor just the cmd's main() function split into embed subpackages.

WDYT?

Gentle ping

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 22, 2024
@cardil cardil force-pushed the feature/go-native-codegen branch from 1cd3950 to cb10688 Compare March 5, 2024 15:32
@cardil cardil marked this pull request as draft March 6, 2024 00:11
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 6, 2024
@cardil cardil force-pushed the feature/go-native-codegen branch 4 times, most recently from 870a5f8 to 1ade5f6 Compare March 6, 2024 00:42
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 6, 2024
@cardil cardil force-pushed the feature/go-native-codegen branch 2 times, most recently from f64d961 to 57629ce Compare March 6, 2024 12:27
@cardil cardil marked this pull request as ready for review March 6, 2024 13:23
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 6, 2024
@cardil cardil force-pushed the feature/go-native-codegen branch 3 times, most recently from 63846df to 701eb12 Compare March 6, 2024 16:58
 * Go-native code-gen entrypoint structure bcedd4a
 * Parsing of gen-client flags 1160fc7
 * Structure for all commands of the K8s code-gen db6a5d7
 * Helpers-gen calls deepcopy-gen aaf0d26
 * Remove unneeded Printer interface eb6748c
 * Setup a default boilerplate 67bcbb0
 * Helper-gen calls defaulter-gen 5b524d1
 * Streamline logging b596957
 * Fixing tests 323501a
 * Helpers-gen calls the conversion-gen 2831fdd
 * Replace shell code with golang tooling 0615e85
 * Fixing lint errors 30a4a7e
 * Auto-skip if git isn't available 79a1e6a
 * Add k8s.io/code-generator to examples go.mod b760ba5
 * Printing stderr when exec.Command fails 7280dd2
 * Update boilerplate 5c27b82
 * Calculate sourcedir from regular sources, not test ones 8bfa3c5
 * Migrate off using `git-*` shell outs to search Go files 7b61cf6
 * Auto-skip failing test when executed in bad GOPATH 079f581
 * Fix lint errors 41d722d
 * Use deepcopy gen fn for deepcopy-gen main 5be3f70
 * Ensure to run codegen main with GO modules 1cd3950
@cardil cardil force-pushed the feature/go-native-codegen branch from 701eb12 to 59892fc Compare March 6, 2024 19:49
@cardil
Copy link
Author

cardil commented Mar 6, 2024

/test pull-kubernetes-verify

It looks like a flaky test (job #1765465013083967488)?

@cardil
Copy link
Author

cardil commented Mar 6, 2024

@upodroid @thockin The PR is ready for reviewing.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@thockin
Copy link
Member

thockin commented Apr 4, 2024

Given https://kubernetes.slack.com/archives/C0EG7JC6T/p1705698354201949 discussion, this is on hold, right?

@cardil
Copy link
Author

cardil commented Apr 11, 2024

Given https://kubernetes.slack.com/archives/C0EG7JC6T/p1705698354201949 discussion, this is on hold, right?

Yes. On hold. Likely to be closed, soon.

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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/XXL Denotes a PR that changes 1000+ 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.

Allow to use the code-gen in vendorless projects
5 participants