-
Notifications
You must be signed in to change notification settings - Fork 439
✨ Generation of typed apply clients using upstream generator #818
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
✨ Generation of typed apply clients using upstream generator #818
Conversation
Skipping CI for Draft Pull Request. |
18594e4
to
74642c2
Compare
pkg/applyconfigurations/gen.go
Outdated
enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) | ||
) | ||
|
||
var importMapping = map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we allow additional import mappings, I know the upstream applyconfiguration gen does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes sense, yeah (But we can do that in a follow-up)
/test all Need to work out how to test this, but want to see what the existing tests do with this so I can fix any failures introduced |
/test all |
filesInMaster := make(map[string][]byte) | ||
masterFileNames := sets.New[string]() | ||
cronJobFS := os.DirFS(".") | ||
masterPath := "applyconfiguration-master" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I can't change the directory to which we are generating the assets currently, this is what I came up with, create a copy that we keep checked in and then diff against that, if there are genuine changes we can update both copies.
Will look at gengo to see if there's a backwards compatible way to allow it to output to different places like OutputRule
does for these generators
/assign @alvaroaleman |
As an option I would love to have the Extract functions, we use them extensively in our operator (for better or for worse). |
@JoelSpeed Can we get rid of the vendor folder? It's probably on my side but the performance of the file tab is pretty bad with 1700 files. |
pkg/applyconfigurations/testdata/cronjob/applyconfiguration-master/internal/internal.go
Outdated
Show resolved
Hide resolved
Second this, I can literally not review this through the GitHub UI |
Sorry about that, must have committed during my experimenting, dropped it now, commit history in need of a good clean though |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For an internal project, I added the +kubebuilder:ac:generate=true
comment both on the package and on my type, running controller-gen
with apply paths=./pkg/api/v1/
succeeds but doesn't generate anything - any idea what I am am doing wrong?
pkg/applyconfigurations/gen.go
Outdated
enableTypeMarker = markers.Must(markers.MakeDefinition("kubebuilder:ac:generate", markers.DescribesType, false)) | ||
) | ||
|
||
var importMapping = map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes sense, yeah (But we can do that in a follow-up)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For an internal project, I added the +kubebuilder:ac:generate=true
comment both on the package and on my type, running controller-gen
with apply paths=./pkg/api/v1/
succeeds but doesn't generate anything - any idea what I am am doing wrong?
Potentially could be: #818 (comment) |
607e978
to
0aa6676
Compare
c599c42
to
804b842
Compare
Thx! /lgtm |
LGTM label has been added. Git tree hash: 51056a1fd6f10be8a831975e810ceb82afa1b23d
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you so much for your work on this!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, JoelSpeed 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 |
…tes-sigs#818) * Stub out generator * Add apply gen to controller-tools * Add code-generator to go.mod * Integrate upstream apply config generator * Cleanup unused code from previous implementation * Convert controller-tools tags to genclient * Add generated clients * Cleanup markers, ensure correct path for non GOPATH * Add test to check generated content against generated master * chore: resolve applyconfig gen correctly * Migrate to gengo v2 * Update generated test data * Ignore testdata for the purposes of go generate * Rename apply command to applyconfiguration * Rename package to applyconfiguration * Rework tests to use temporary directory for output files * Update cronjob_types with the latest version * Update groupversion inline with latest kubebuilder * Update go.mod to match latest of top level * Move test apis into an API v1 folder to be more accurate * Add test for generating client outside of API directory * Address feedback on gen.go --------- Co-authored-by: Joe Betz <[email protected]> Co-authored-by: Jefftree <[email protected]> Co-authored-by: Jakob Möller <[email protected]>
This integrates the upstream applyconfig generator into controller-tools to allow generation of ApplyConfig style types from custom API types.
The aim here is to provide the pointer style structs that could then be passed to an Apply style method for using server side apply.
Setting this up as a WIP PR for now, current TODO list: