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
@@ -25,22 +25,26 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { PodSecurityPolicy } from "../../../common/k8s-api/endpoints";
|
||||
import { PodSecurityPolicy } from "../../../common/k8s-api/endpoints";
|
||||
import { Badge } from "../badge";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import { KubeObjectMeta } from "../kube-object-meta";
|
||||
import logger from "../../../common/logger";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<PodSecurityPolicy> {
|
||||
}
|
||||
|
||||
interface RuleGroup {
|
||||
rule: string;
|
||||
ranges?: {
|
||||
max: number;
|
||||
min: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PodSecurityPolicyDetails extends React.Component<Props> {
|
||||
renderRuleGroup(
|
||||
title: React.ReactNode,
|
||||
group: {
|
||||
rule: string;
|
||||
ranges?: { max: number; min: number }[];
|
||||
}) {
|
||||
renderRuleGroup( title: React.ReactNode, group: RuleGroup) {
|
||||
if (!group) return null;
|
||||
const { rule, ranges } = group;
|
||||
|
||||
@@ -67,6 +71,13 @@ export class PodSecurityPolicyDetails extends React.Component<Props> {
|
||||
if (!psp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(psp instanceof PodSecurityPolicy)) {
|
||||
logger.error("[PodSecurityPolicyDetails]: passed object that is not an instanceof PodSecurityPolicy", psp);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
allowedHostPaths, allowedCapabilities, allowedCSIDrivers, allowedFlexVolumes, allowedProcMountTypes,
|
||||
allowedUnsafeSysctls, allowPrivilegeEscalation, defaultAddCapabilities, forbiddenSysctls, fsGroup,
|
||||
@@ -172,14 +183,14 @@ export class PodSecurityPolicyDetails extends React.Component<Props> {
|
||||
<TableCell>Path Prefix</TableCell>
|
||||
<TableCell>Read-only</TableCell>
|
||||
</TableHead>
|
||||
{allowedHostPaths.map(({ pathPrefix, readOnly }, index) => {
|
||||
return (
|
||||
{
|
||||
allowedHostPaths.map(({ pathPrefix, readOnly }, index) => (
|
||||
<TableRow key={index}>
|
||||
<TableCell>{pathPrefix}</TableCell>
|
||||
<TableCell>{readOnly ? "Yes" : "No"}</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
))
|
||||
}
|
||||
</Table>
|
||||
</>
|
||||
)}
|
||||
@@ -193,7 +204,7 @@ export class PodSecurityPolicyDetails extends React.Component<Props> {
|
||||
<>
|
||||
<DrawerTitle title="Runtime Class"/>
|
||||
<DrawerItem name="Allowed Runtime Class Names">
|
||||
{(runtimeClass.allowedRuntimeClassNames || []).join(", ") || "-"}
|
||||
{runtimeClass.allowedRuntimeClassNames?.join(", ") || "-"}
|
||||
</DrawerItem>
|
||||
<DrawerItem name="Default Runtime Class Name">
|
||||
{runtimeClass.defaultRuntimeClassName || "-"}
|
||||
|
||||
Reference in new issue
Block a user