K8s: Register group and kinds to internal version to fix apply (#97184)

* K8s: Register group and kinds to internal version to fix apply
This commit is contained in:
Karl Persson 2024-12-02 10:32:34 +01:00 committed by GitHub
parent 14b49a0f61
commit 7b25804b55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,6 +64,16 @@ func (b *appBuilder) InstallSchema(scheme *runtime.Scheme) error {
for _, kind := range kinds {
scheme.AddKnownTypeWithName(gv.WithKind(kind.Kind()), kind.ZeroValue())
scheme.AddKnownTypeWithName(gv.WithKind(kind.Kind()+"List"), kind.ZeroListValue())
// Link this group to the internal representation.
// This is used for server-side-apply (PATCH), and avoids the error:
// "no kind is registered for the type"
gvInternal := schema.GroupVersion{
Group: gv.Group,
Version: runtime.APIVersionInternal,
}
scheme.AddKnownTypeWithName(gvInternal.WithKind(kind.Kind()), kind.ZeroValue())
scheme.AddKnownTypeWithName(gvInternal.WithKind(kind.Kind()+"List"), kind.ZeroListValue())
}
}
return scheme.SetVersionPriority(gv)