-
Notifications
You must be signed in to change notification settings - Fork 399
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
⚠️ New Generation Framework and Generators #200
⚠️ New Generation Framework and Generators #200
Conversation
Don't accidentally check in ViM swap files, etc.
This introduces utilities for incremental/filtered package loading, based on go/packages (the new replacement for go/build and friends when importing). It'll work with modules properly, too.
This introduces a framework for collecting and parsing "marker" comments into structured Go data, much like the "json" package.
This removed the generation and parsing logic that's being superseded by loader, markers, etc.
This adds a generator framework that ties together running multiple generators from the same marker data, and describe how they can read and write artifacts.
This adds RBAC generation (as per our existing RBAC markers) on top of the new generator framework.
This defines the framework for CRD generation, and uses markers with that implement interfaces to modify the schema and CRD.
This implements deepcopy generation, mostly copying from deepcopy-gen but using the generator framework. It slightly scopes down things to only implement parts we care about for custom types that represent CRDs.
This updates controller-gen to make use of the new generator framework. Generators and ouput rules are treated as markers to parse commandline options.
This adds WebhookConfig generation (as per our existing webhook markers, with slight modifications) on top of the new generator framework.
Update deps to required versions.
It's no longer used by any tests. We can always add it back in if we need to.
Some of the enabled checkers were deprecated, had known issues, or returned erroneous results. They've been commented out, with comments as to why they're not run.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12 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 |
Additional thanks to @redborian and @mengqiy for a bunch of the initial CRD generation revamp work that preceded the new framework. |
It feels fitting that this is Issue/PR 200 :-) |
/lgtm |
This introduces a new marker (tag) parsing and generation framework that should help easy feature addition and longterm development, as well as improve the UX of using controller-tools with different project layouts, including the new kubebuilder scaffolding v2 layout in development.
The framework itself is broken up across several packages, each of which has an overview godoc page on how it works and the logic behind it.
The core framework is composed of:
pkg/loader
: file loading and low-level type traversalpkg/markers
: marker parsing and high-level type traversalpkg/genall
: managing and running generators from shared parsing stateAdditionally, the following generators exist, all of which can be called directly as a "library"
pkg/crd
: CRD and OpenAPI schema generation (lower-level bits are standalone, and can be used directly)pkg/deepcopy
: CRD-specific replacement for deepcopy-genpkg/webhook
: WebhookConfig generationpkg/rbac
: ClusterRole generationAll generators are tied together in the new version of the
controller-gen
command. Thecontroller-gen
command takes generator and output arguments using the same syntax as the markers, without the leading plus. Run with--help
for help and examples. You can also use the-w
flag to check which markers a given generator can consume (for example,controller-gen crd -w
will show all the validation and versioning markers).