Skip to content

Commit 3281ac6

Browse files
Merge pull request #4448 from pallava-joshi/fix/make-customResourceDefinition-optional
frontend: lib/k8s/crd: Made customResourceDefinition optional in CRClassArgs
1 parent 5afe911 commit 3281ac6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

frontend/src/lib/k8s/crd.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,20 @@ export function makeCustomResourceClass(
195195
static getBaseObject(): Omit<KubeObjectInterface, 'metadata'> & {
196196
metadata: Partial<import('./KubeMetadata').KubeMetadata>;
197197
} {
198-
if (!crClassArgs.customResourceDefinition) {
199-
return super.getBaseObject();
198+
// For custom resources - use the storage version from the CRD if available,
199+
// otherwise fall back to the first apiInfo entry
200+
let group: string;
201+
let version: string;
202+
if (crClassArgs.customResourceDefinition) {
203+
[group, version] = crClassArgs.customResourceDefinition.getMainAPIGroup();
204+
} else {
205+
if (!apiInfoArgs.length) {
206+
throw new Error(
207+
'makeCustomResourceClass requires at least one apiInfo entry when customResourceDefinition is not provided'
208+
);
209+
}
210+
[group, version] = apiInfoArgs[0];
200211
}
201-
202-
const [group, version] = crClassArgs.customResourceDefinition.getMainAPIGroup();
203212
const apiVersion = group ? `${group}/${version}` : version;
204213

205214
return {

0 commit comments

Comments
 (0)