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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 crdgen: compare metav1 pkg by ID #681

Merged
merged 2 commits into from May 31, 2022

Conversation

akutz
Copy link
Contributor

@akutz akutz commented May 25, 2022

This patch updates the way the CRD generator compares an imported metav1 package. Previously the comparison occurred using a Golang equality operator, !=, against two, in-memory data structures. However, this fails when multiple root paths are loaded. Their metav1 packages are identical, just not identical objects in memory. This patch updates the comparison to compare the package IDs, not the instance of the object.

This patch also introduces a filesystem-path specific loader for each unique filesystem path provided as a root. This ensures the AST is loaded correctly and the kubebuilder markers are parsed as intended.

For more information please refer to this Slack thread.

Fixes #680

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 25, 2022
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 25, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label May 25, 2022
@ahmetb
Copy link
Member

ahmetb commented May 25, 2022

needs to be rebased on top of #682

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 25, 2022
This patch updates the way the CRD generator compares an imported
metav1 package. Previously the comparison occurred using a Golang
equality operator, !=, against two, in-memory data structures.
However, this fails when multiple root paths are loaded. Their
metav1 packages are identical, just not identical objects in
memory. This patch updates the comparison to compare the package
IDs, not the instance of the object.

This patch also introduces a filesystem-path specific loader for
each unique filesystem path provided as a root. This ensures the
AST is loaded correctly and the kubebuilder markers are parsed as
intended.
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 30, 2022
@akutz akutz force-pushed the bugfix/680 branch 3 times, most recently from 480c6f3 to 00862e7 Compare May 31, 2022 05:08
This patch adds tests to reproduce the issue of the markers
not being discovered when multiple paths are used.

The issue is not markers missing from a type, but markers missing
from a *referenced* type. For example, the new Job type imports
the unserved.CronJobSpec as the field Job.Spec.CronJob. The
markers are not generated for Job.Spec.CronJob as it is referenced
from another package.
@alvaroaleman
Copy link
Member

/label tide/merge-method-squash
/lgtm
/approve
/cherrypick release-0.9

Thanks for all your work!

@k8s-infra-cherrypick-robot

@alvaroaleman: once the present PR merges, I will cherry-pick it on top of release-0.9 in a new PR and assign it to you.

In response to this:

/label tide/merge-method-squash
/lgtm
/approve
/cherrypick release-0.9

Thanks for all your work!

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 tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 31, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 31, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akutz, alvaroaleman

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 31, 2022
@k8s-ci-robot k8s-ci-robot merged commit ea90e81 into kubernetes-sigs:master May 31, 2022
@k8s-infra-cherrypick-robot

@alvaroaleman: new pull request created: #686

In response to this:

/label tide/merge-method-squash
/lgtm
/approve
/cherrypick release-0.9

Thanks for all your work!

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.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

controller-gen v0.9.0 does not generate CRDs for additional paths
5 participants