mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Check object instanceof on all detail panels (#4054)
* Check object instanceof on all detail panels Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix unit tests - Remove prettier as snapShot testing is too tight of a bound Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
dabfce3609
commit
052d12fc19
32 files changed
+392
-168
No files matched your search
@@ -24,7 +24,7 @@ import "./crd-details.scss";
|
||||
import React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { observer } from "mobx-react";
|
||||
import type { CustomResourceDefinition } from "../../../common/k8s-api/endpoints/crd.api";
|
||||
import { CustomResourceDefinition } from "../../../common/k8s-api/endpoints/crd.api";
|
||||
import { cssNames } from "../../utils";
|
||||
import { ThemeStore } from "../../theme.store";
|
||||
import { Badge } from "../badge";
|
||||
@@ -35,6 +35,7 @@ import { Input } from "../input";
|
||||
import { KubeObjectMeta } from "../kube-object-meta";
|
||||
import MonacoEditor from "react-monaco-editor";
|
||||
import { UserStore } from "../../../common/user-store";
|
||||
import logger from "../../../common/logger";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<CustomResourceDefinition> {
|
||||
}
|
||||
@@ -44,7 +45,16 @@ export class CRDDetails extends React.Component<Props> {
|
||||
render() {
|
||||
const { object: crd } = this.props;
|
||||
|
||||
if (!crd) return null;
|
||||
if (!crd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(crd instanceof CustomResourceDefinition)) {
|
||||
logger.error("[CRDDetails]: passed object that is not an instanceof CustomResourceDefinition", crd);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const { plural, singular, kind, listKind } = crd.getNames();
|
||||
const printerColumns = crd.getPrinterColumns();
|
||||
const validation = crd.getValidation();
|
||||
|
||||
@@ -30,9 +30,10 @@ import { DrawerItem } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeObjectMeta } from "../kube-object-meta";
|
||||
import { Input } from "../input";
|
||||
import type { AdditionalPrinterColumnsV1, CustomResourceDefinition } from "../../../common/k8s-api/endpoints/crd.api";
|
||||
import { AdditionalPrinterColumnsV1, CustomResourceDefinition } from "../../../common/k8s-api/endpoints/crd.api";
|
||||
import { parseJsonPath } from "../../utils/jsonPath";
|
||||
import type { KubeObject, KubeObjectMetadata, KubeObjectStatus } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject, KubeObjectMetadata, KubeObjectStatus } from "../../../common/k8s-api/kube-object";
|
||||
import logger from "../../../common/logger";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<KubeObject> {
|
||||
crd: CustomResourceDefinition;
|
||||
@@ -101,6 +102,18 @@ export class CrdResourceDetails extends React.Component<Props> {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(object instanceof KubeObject)) {
|
||||
logger.error("[CrdResourceDetails]: passed object that is not an instanceof KubeObject", object);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(crd instanceof CustomResourceDefinition)) {
|
||||
logger.error("[CrdResourceDetails]: passed crd that is not an instanceof CustomResourceDefinition", crd);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const extraColumns = crd.getPrinterColumns();
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user