@@ -165,13 +165,58 @@ export function normalizeResponseHeaders(response: Response): { [key: string]: s
165165 return normalizedHeaders ;
166166}
167167
168- export function getSerializationType ( apiVersion ?: string , kind ?: string ) : string {
168+ /**
169+ * Built-in Kubernetes API groups that have generated TypeScript models.
170+ * Custom resources and third-party API groups (like Knative) are not included.
171+ */
172+ const BUILT_IN_API_GROUPS = new Set ( [
173+ 'core' , // maps to "" (empty string) for core resources like Pod, Service, etc.
174+ 'admissionregistration.k8s.io' ,
175+ 'apiextensions.k8s.io' ,
176+ 'apiregistration.k8s.io' ,
177+ 'apps' ,
178+ 'authentication.k8s.io' ,
179+ 'authorization.k8s.io' ,
180+ 'autoscaling' ,
181+ 'batch' ,
182+ 'certificates.k8s.io' ,
183+ 'coordination.k8s.io' ,
184+ 'discovery.k8s.io' ,
185+ 'events.k8s.io' ,
186+ 'flowcontrol.apiserver.k8s.io' ,
187+ 'internal.apiserver.k8s.io' ,
188+ 'networking.k8s.io' ,
189+ 'node.k8s.io' ,
190+ 'policy' ,
191+ 'rbac.authorization.k8s.io' ,
192+ 'resource.k8s.io' ,
193+ 'scheduling.k8s.io' ,
194+ 'storage.k8s.io' ,
195+ 'storagemigration.k8s.io' ,
196+ ] ) ;
197+
198+ /**
199+ * Check if the given API group is a built-in Kubernetes API group.
200+ * @param group - The API group to check (e.g., "apps", "serving.knative.dev", "core")
201+ * @returns true if the group is a built-in Kubernetes API group, false otherwise
202+ */
203+ function isBuiltInApiGroup ( group : string ) : boolean {
204+ return BUILT_IN_API_GROUPS . has ( group ) ;
205+ }
206+
207+ export function getSerializationType ( apiVersion ?: string , kind ?: string ) : string | undefined {
169208 if ( apiVersion === undefined || kind === undefined ) {
170209 return 'KubernetesObject' ;
171210 }
172211 // Types are defined in src/gen/api/models with the format "<Version><Kind>".
173212 // Version and Kind are in PascalCase.
174213 const gv = groupVersion ( apiVersion ) ;
214+
215+ // Only return a type name if this is a built-in Kubernetes API group
216+ if ( ! isBuiltInApiGroup ( gv . group ) ) {
217+ return undefined ;
218+ }
219+
175220 const version = gv . version . charAt ( 0 ) . toUpperCase ( ) + gv . version . slice ( 1 ) ;
176221 return `${ version } ${ kind } ` ;
177222}
0 commit comments