-
Notifications
You must be signed in to change notification settings - Fork 388
chore: Add AddToScheme pattern to v1 API version
#2565
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
base: main
Are you sure you want to change the base?
Conversation
|
Welcome @zamai! |
|
Hi @zamai. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
This commit introduces AddToScheme, registers NodePool, NodePoolList, NodeClaim, and NodeClaimList types within the scheme. add test files remove test
f1202f5 to
dc95072
Compare
Pull Request Test Coverage Report for Build 19195221923Details
💛 - Coveralls |
|
/retest |
|
@zamai: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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-sigs/prow repository. |
| AddToScheme = SchemeBuilder.AddToScheme | ||
| ) | ||
|
|
||
| func addKnownTypes(s *runtime.Scheme) error { |
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.
nit: How do you feel about:
| func addKnownTypes(s *runtime.Scheme) error { | |
| func (s *runtime.Scheme) addKnownTypes() { |
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 feel okay about it, but I used runtime.NewSchemeBuilder which accepts function with this signature:
NewSchemeBuilder(funcs ...func(*Scheme) error) SchemeBuilder
I was following the same pattern I saw other packages implement, example:
https://github.com/argoproj/argo-rollouts/blob/92f4801475175abc888f7a29fee63fd965e15c14/pkg/apis/rollouts/v1alpha1/register.go#L35
DerekFrank
left a comment
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.
Do you have any examples of controllers that follow this type of pattern that could be refactored?
| GroupVersion = schema.GroupVersion{Group: apis.Group, Version: "v1"} | ||
|
|
||
| // SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
| SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) |
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.
If i'm not mistaken, this includes several different options for adding known types, as you could call:
v1.SchemeBuilder.Build()
as well. Is this intentional?
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.
It was intentionally copping this registration from go-client:
https://github.com/kubernetes/client-go/blob/d9e3e97bc805a0a2936112b8a33b78be27b09eec/scale/scheme/register.go
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: moko-poi, zamai The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Many Kubernetes controllers and integration tests rely on AddToScheme helpers to register CRDs. Adding this function to Karpenter simplifies setup, and aligns with standard Kubernetes API patterns.
This PR adds AddToScheme support for Karpenter API types, enabling them to be registered with a runtime.Scheme. This makes it straightforward for external controllers, tests, and tools to use Karpenter’s types with controller-runtime clients, decoders, and webhooks without manual type registration.
Example how currently I register these types:
After Fix:
How was this change tested?
Manually, and I've generated some tests locally, but I feel that they might be unnecessary in the repo.
Please let me know if adding tests for this variable would a requirement, to merge.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.