-
Notifications
You must be signed in to change notification settings - Fork 98
K8s 1.30 #425
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
K8s 1.30 #425
Conversation
6c5fa27
to
16e53c8
Compare
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.
There's one other place that we should update the go version of:
wrangler/.github/workflows/lint.yaml
Line 4 in 2a768fd
SETUP_GO_VERSION: '^1.21' |
9a06fb0
to
4c6d7f0
Compare
Recent changes:
|
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.
Two comments on how we are structuring the package path.
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.
LGTM
Issue rancher/rancher#45324
Wrangler relies on
k8s.io/code-generator
for some of its generators. Starting with k8s 1.30, these generators have been migrated, in a backward incompatible way, fromk8s.io/gengo
tok8s.io/gengo/v2
. We must adapt the code with the new major version of gengo.Changes in
gengo/v2
GeneratorArgs
One major change in the API is that before, you had to create a GeneratorArgs. It contained information such as: InputDirs to point to directories that need codegen, OutputBase to specify a directory tree to write file to, CustomArgs for generator-specific information.
This struct is no longer used in
gengo/v2
, and instead is replaced in the following way:InputDirs
: This is now provided in a new argument to the Execute function.OutputBase
: Generators would compute "output file = <output base>/<package>/...
" to know which directory the generated file needs to be in. By convention, generators now expects an absolute path to the destination directory. For example:CustomArgs
: Custom args aren't part of the API anymore. If theTarget
/Generator
needs custom arguments, you must find another way of passing it to it. By convention it's done by having aGetTarget
function that accepts such an argument, and wrapping it by a function that doesn't accept it. Here's an example:DefaultGen
generator.DefaultGen is replaced by generator.GoGenerator. The impact is that we must specify
.go
suffix to all filenames ourselves. This changes the generator name to have this.go
suffix, which itself changes some comments in the generated output.DefaultPackage
generator.DefaultPackage is replaced by generator.SimpleTarget.
Commits
To make it easier to review, I have split the changes in multiple commits. Not every commit is self-contained (so don't try to
go build
them individually).1. go-imports
Cherry-picked from #416.
2. Upgrade k8s to v1.30
Bumps the following:
3. DeepCopy generator
Not much changed here. We're now referencing gengo directly instead of k8s.io/code-generator's newtype We were already using the generator from
gengo/v1
, which is still available to us.4. ClientSet generator
Migrates the clientset generator to gengo/v2.
5. Listers generator
Migrates the listers generator to gengo/v2.
6. Informers generator
Migrates the informers generator to gengo/v2.
7. setGenClient middleware
I haven't change the logic of this function. It acts as some kind of middleware. It used to passthrough the arguments to the next function. Since that's no longer part of the
gengo/v2
api, we're no longer doing this.8. Migrate custom generators
As mentioned in the "Changes in
gengo/v2
" section, generators now embed agenerator.GoGenerator
instead. Anything referencingPackage
should now be namedTarget
. For example, I renamed the functionPackage
toTarget
and it now returns aSimpleTarget
.The boilerplate information is read only once as opposed to be read for every generator. The goal wasn't to optimize, but to avoid passing the
GeneratorArgs
fromgengo/v1
.