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

🌱 Enhancements to how controller-gen is invoked #1911

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Feb 27, 2024

This PR includes 2 commits which each make a single change to how the Makefile does code generation.

The first adds the following 2 separate targets:

  • generate-controller-gen
  • generate-conversion-gen

These invoke controller-gen and conversion-gen respectively. These were previously invoked by the generate-go target, but that target is now reduced to simply executing go generate ./....

The generate target continues to invoke all code generation.

The advantage of this is the ability to easily run only the generation you need during development.

The second commit changes the behaviour of generate-conversion-gen. This produces no change in output against the current codebase, but fixes an issue generating an incorrect package internal package name should conversion-gen want to add a dependency between packages. I encountered this when I made a change which caused it to do this, which has not yet landed.

generate-controller-gen and generate-conversion-gen targets are split
out of generate-go
When conversion-gen has to generate a dependency between 2 input
packages it uses the value passed to --input-dirs as the package name in
the generated import. This does not work if that value is a directory
name. If you specify a package name here instead it works correctly.

We also stop trying to generate conversions for versions which don't
need them.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 27, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 27, 2024
Copy link

netlify bot commented Feb 27, 2024

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit 4bb8966
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/65de2273d3324e00081b2c9b
😎 Deploy Preview https://deploy-preview-1911--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

--input-dirs=./api/v1beta1 \
--input-dirs=$(capo_module)/api/v1alpha5 \
--input-dirs=$(capo_module)/api/v1alpha6 \
--input-dirs=$(capo_module)/api/v1alpha7 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why v1beta1 is missing but I won't block you on that, maybe there is a reason behind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's deliberately excluded because we don't need to generate conversions for v1beta1 (or v1alpha1).

Copy link
Contributor

@EmilienM EmilienM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/hold
for a question that I have, but feel free to hold cancel if it's all good.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 27, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 27, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: EmilienM, mdbooth

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

The pull request process is described 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

@mdbooth
Copy link
Contributor Author

mdbooth commented Feb 27, 2024

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 27, 2024
@k8s-ci-robot k8s-ci-robot merged commit c0b54d0 into kubernetes-sigs:main Feb 27, 2024
9 checks passed
@mdbooth mdbooth deleted the conversion-gen branch February 27, 2024 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants