Update dependencies to Kubernetes 1.36.0 #855
Open
stefanprodan wants to merge 2 commits intomainfrom
Open
Conversation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
matheuscscp
approved these changes
May 9, 2026
Comment on lines
+19
to
+42
| // schemeBuilder accumulates the type registration functions for this API group. | ||
| schemeBuilder runtime.SchemeBuilder | ||
|
|
||
| // SchemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
| SchemeBuilder = &groupVersionBuilder{} | ||
|
|
||
| // AddToScheme adds the types in this group-version to the given scheme. | ||
| AddToScheme = SchemeBuilder.AddToScheme | ||
| AddToScheme = schemeBuilder.AddToScheme | ||
| ) | ||
|
|
||
| // groupVersionBuilder registers Go types with the package's GroupVersion. | ||
| // It replaces the deprecated sigs.k8s.io/controller-runtime/pkg/scheme.Builder | ||
| // so that this API package depends only on k8s.io/apimachinery. | ||
| type groupVersionBuilder struct{} | ||
|
|
||
| // Register schedules the given runtime.Object types to be added to the scheme | ||
| // under the package's GroupVersion when AddToScheme is called. | ||
| func (b *groupVersionBuilder) Register(objects ...runtime.Object) { | ||
| schemeBuilder.Register(func(s *runtime.Scheme) error { | ||
| s.AddKnownTypes(GroupVersion, objects...) | ||
| metav1.AddToGroupVersion(s, GroupVersion) | ||
| return nil | ||
| }) | ||
| } |
Member
There was a problem hiding this comment.
Interesting approach, the comment on the deprecated scheme.Builder is the following:
(and that's what I did here... wondering if it's flawed...)
// Builder builds a new Scheme for mapping go types to Kubernetes GroupVersionKinds.
//
// Deprecated: This helper is only useful in api packages, but api packages should be
// easy to import and hence have minimal dependencies. Typically, these dependencies
// include only the standard library, k8s.io/apimachinery and other api packages.
//
// Use the apimachinery builder instead:
//
// import (
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// "k8s.io/apimachinery/pkg/runtime"
// "k8s.io/apimachinery/pkg/runtime/schema"
// )
//
// const GroupName = ""
//
// var (
// SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
// SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
// AddToScheme = SchemeBuilder.AddToScheme
// )
//
// func addKnownTypes(scheme *runtime.Scheme) error {
// scheme.AddKnownTypes(SchemeGroupVersion,
// &Pod{},
// )
//
// metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
// return nil
// }
type Builder struct {
GroupVersion schema.GroupVersion
runtime.SchemeBuilder
}
Member
Author
There was a problem hiding this comment.
I like that each type handles its own registration. Adding a new CRD and registering it happen in the same file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xref: fluxcd/flux2#5864