mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix CRD.getPreferedVersion() to work based on apiVersion
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
41e7664fe2
commit
3d7690c58b
@ -150,27 +150,29 @@ export class CustomResourceDefinition extends KubeObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPreferedVersion(): CRDVersion {
|
getPreferedVersion(): CRDVersion {
|
||||||
// Prefer the modern `versions` over the legacy `version`
|
const { apiVersion } = this;
|
||||||
if (this.spec.versions) {
|
|
||||||
for (const version of this.spec.versions) {
|
switch (apiVersion) {
|
||||||
if (version.storage) {
|
case "apiextensions.k8s.io/v1":
|
||||||
return version;
|
for (const version of this.spec.versions) {
|
||||||
|
if (version.storage) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
case "apiextensions.k8s.io/v1beta1":
|
||||||
} else if (this.spec.version) {
|
const { additionalPrinterColumns: apc } = this.spec;
|
||||||
const { additionalPrinterColumns: apc } = this.spec;
|
const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc }) => ({ ...apc, jsonPath: JSONPath }));
|
||||||
const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc }) => ({ ...apc, jsonPath: JSONPath }));
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: this.spec.version,
|
name: this.spec.version,
|
||||||
served: true,
|
served: true,
|
||||||
storage: true,
|
storage: true,
|
||||||
schema: this.spec.validation,
|
schema: this.spec.validation,
|
||||||
additionalPrinterColumns,
|
additionalPrinterColumns,
|
||||||
};
|
};
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown apiVersion=${apiVersion}: Failed to find a version for CustomResourceDefinition ${this.metadata.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Failed to find a version for CustomResourceDefinition ${this.metadata.name}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getVersion() {
|
getVersion() {
|
||||||
@ -197,7 +199,7 @@ export class CustomResourceDefinition extends KubeObject {
|
|||||||
const columns = this.getPreferedVersion().additionalPrinterColumns ?? [];
|
const columns = this.getPreferedVersion().additionalPrinterColumns ?? [];
|
||||||
|
|
||||||
return columns
|
return columns
|
||||||
.filter(column => column.name != "Age" && (ignorePriority || !column.priority));
|
.filter(column => column.name.toLowerCase() != "age" && (ignorePriority || !column.priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
getValidation() {
|
getValidation() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user