File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import type { QueryParameters } from './api/v1/queryParameters';
3131import type { ApiError } from './api/v2/ApiError' ;
3232import { useKubeObject } from './api/v2/hooks' ;
3333import { makeListRequests , useKubeObjectList } from './api/v2/useKubeObjectList' ;
34+ import type CustomResourceDefinition from './crd' ;
3435import type { KubeEvent } from './event' ;
3536import type { KubeMetadata , KubeMetadataCreate } from './KubeMetadata' ;
3637
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ class CustomResourceDefinition extends KubeObject<KubeCRD> {
103103 for ( const versionItem of this . spec . versions ) {
104104 if ( ! ! versionItem . storage ) {
105105 version = versionItem . name ;
106+ break ;
106107 } else if ( ! version ) {
107108 version = versionItem . name ;
108109 }
@@ -190,6 +191,22 @@ export function makeCustomResourceClass(
190191 static isNamespaced = objArgs . isNamespaced ;
191192 static apiEndpoint = apiFunc ( ...apiInfoArgs ) ;
192193 static customResourceDefinition = crClassArgs . customResourceDefinition ;
194+
195+ static getBaseObject ( ) : Omit < KubeObjectInterface , 'metadata' > & {
196+ metadata : Partial < import ( './KubeMetadata' ) . KubeMetadata > ;
197+ } {
198+ // For custom resources, use the storage version from the CRD
199+ const [ group , version ] = crClassArgs . customResourceDefinition . getMainAPIGroup ( ) ;
200+ const apiVersion = group ? `${ group } /${ version } ` : version ;
201+
202+ return {
203+ apiVersion,
204+ kind : this . kind ,
205+ metadata : {
206+ name : '' ,
207+ } ,
208+ } ;
209+ }
193210 } ;
194211}
195212
You can’t perform that action at this time.
0 commit comments