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

⚠️ New Generation Framework and Generators #200

Merged

Conversation

DirectXMan12
Copy link
Contributor

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 traversal
  • pkg/markers: marker parsing and high-level type traversal
  • pkg/genall: managing and running generators from shared parsing state

Additionally, 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-gen
  • pkg/webhook: WebhookConfig generation
  • pkg/rbac: ClusterRole generation

All generators are tied together in the new version of the controller-gen command. The controller-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).

redborian and others added 17 commits May 3, 2019 23:55
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.
@k8s-ci-robot
Copy link
Contributor

[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 /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 4, 2019
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 4, 2019
@DirectXMan12
Copy link
Contributor Author

Additional thanks to @redborian and @mengqiy for a bunch of the initial CRD generation revamp work that preceded the new framework.

@DirectXMan12
Copy link
Contributor Author

It feels fitting that this is Issue/PR 200 :-)

@mengqiy
Copy link
Member

mengqiy commented May 6, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 6, 2019
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants