mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Lens app source code (#119)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
936cbd53d4
commit
1d0815abd2
797 files changed
+73714
-215
No files matched your search
@@ -0,0 +1,3 @@
|
||||
export * from "./pod-security-policies.route"
|
||||
export * from "./pod-security-policies"
|
||||
export * from "./pod-security-policy-details"
|
||||
@@ -0,0 +1,8 @@
|
||||
import { RouteProps } from "react-router"
|
||||
import { buildURL } from "../../navigation";
|
||||
|
||||
export const podSecurityPoliciesRoute: RouteProps = {
|
||||
path: "/pod-security-policies"
|
||||
}
|
||||
|
||||
export const podSecurityPoliciesURL = buildURL(podSecurityPoliciesRoute.path)
|
||||
@@ -0,0 +1,9 @@
|
||||
.PodSecurityPolicies {
|
||||
.Table {
|
||||
.TableCell {
|
||||
&.volumes {
|
||||
flex-grow: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { PodSecurityPolicy, pspApi } from "../../api/endpoints";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@autobind()
|
||||
export class PodSecurityPoliciesStore extends KubeObjectStore<PodSecurityPolicy> {
|
||||
api = pspApi
|
||||
}
|
||||
|
||||
export const podSecurityPoliciesStore = new PodSecurityPoliciesStore()
|
||||
apiManager.registerStore(pspApi, podSecurityPoliciesStore);
|
||||
@@ -0,0 +1,69 @@
|
||||
import "./pod-security-policies.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||
import { podSecurityPoliciesStore } from "./pod-security-policies.store";
|
||||
import { PodSecurityPolicy, pspApi } from "../../api/endpoints";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
enum sortBy {
|
||||
name = "name",
|
||||
volumes = "volumes",
|
||||
privileged = "privileged",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PodSecurityPolicies extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
className="PodSecurityPolicies"
|
||||
isClusterScoped={true}
|
||||
store={podSecurityPoliciesStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: PodSecurityPolicy) => item.getName(),
|
||||
[sortBy.volumes]: (item: PodSecurityPolicy) => item.getVolumes(),
|
||||
[sortBy.privileged]: (item: PodSecurityPolicy) => +item.isPrivileged(),
|
||||
[sortBy.age]: (item: PodSecurityPolicy) => item.getAge(false),
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: PodSecurityPolicy) => item.getSearchFields(),
|
||||
(item: PodSecurityPolicy) => item.getVolumes(),
|
||||
(item: PodSecurityPolicy) => Object.values(item.getRules()),
|
||||
]}
|
||||
renderHeaderTitle={<Trans>Pod Security Policies</Trans>}
|
||||
renderTableHeader={[
|
||||
{ title: <Trans>Name</Trans>, className: "name", sortBy: sortBy.name },
|
||||
{ title: <Trans>Privileged</Trans>, className: "privileged", sortBy: sortBy.privileged },
|
||||
{ title: <Trans>Volumes</Trans>, className: "volumes", sortBy: sortBy.volumes },
|
||||
{ title: <Trans>Age</Trans>, className: "age", sortBy: sortBy.age },
|
||||
]}
|
||||
renderTableContents={(item: PodSecurityPolicy) => {
|
||||
return [
|
||||
item.getName(),
|
||||
item.isPrivileged() ? <Trans>Yes</Trans> : <Trans>No</Trans>,
|
||||
item.getVolumes().join(", "),
|
||||
item.getAge(),
|
||||
]
|
||||
}}
|
||||
renderItemMenu={(item: PodSecurityPolicy) => {
|
||||
return <PodSecurityPolicyMenu object={item}/>
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export function PodSecurityPolicyMenu(props: KubeObjectMenuProps<PodSecurityPolicy>) {
|
||||
return (
|
||||
<KubeObjectMenu {...props}/>
|
||||
)
|
||||
}
|
||||
|
||||
apiManager.registerViews(pspApi, {
|
||||
Menu: PodSecurityPolicyMenu,
|
||||
})
|
||||
@@ -0,0 +1,2 @@
|
||||
.PodSecurityPolicyDetails {
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
import "./pod-security-policy-details.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Trans } from "@lingui/macro";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { PodSecurityPolicy, pspApi } from "../../api/endpoints";
|
||||
import { Badge } from "../badge";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<PodSecurityPolicy> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class PodSecurityPolicyDetails extends React.Component<Props> {
|
||||
renderRuleGroup(
|
||||
title: React.ReactNode,
|
||||
group: {
|
||||
rule: string;
|
||||
ranges?: { max: number; min: number }[];
|
||||
}) {
|
||||
if (!group) return;
|
||||
const { rule, ranges } = group;
|
||||
return (
|
||||
<>
|
||||
<DrawerTitle title={title}/>
|
||||
<DrawerItem name={<Trans>Rule</Trans>}>
|
||||
{rule}
|
||||
</DrawerItem>
|
||||
{ranges && (
|
||||
<DrawerItem name={<Trans>Ranges (Min-Max)</Trans>} labelsOnly>
|
||||
{ranges.map(({ min, max }, index) => {
|
||||
return <Badge key={index} label={`${min} - ${max}`}/>
|
||||
})}
|
||||
</DrawerItem>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { object: psp } = this.props;
|
||||
if (!psp) {
|
||||
return null;
|
||||
}
|
||||
const {
|
||||
allowedHostPaths, allowedCapabilities, allowedCSIDrivers, allowedFlexVolumes, allowedProcMountTypes,
|
||||
allowedUnsafeSysctls, allowPrivilegeEscalation, defaultAddCapabilities, defaultAllowPrivilegeEscalation,
|
||||
forbiddenSysctls, fsGroup, hostIPC, hostNetwork, hostPID, hostPorts, privileged, readOnlyRootFilesystem,
|
||||
requiredDropCapabilities, runAsGroup, runAsUser, runtimeClass, seLinux, supplementalGroups, volumes
|
||||
} = psp.spec;
|
||||
return (
|
||||
<div className="PodSecurityPolicyDetails">
|
||||
<KubeObjectMeta object={psp}/>
|
||||
|
||||
{allowedCapabilities && (
|
||||
<DrawerItem name={<Trans>Allowed Capabilities</Trans>}>
|
||||
{allowedCapabilities.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{volumes && (
|
||||
<DrawerItem name={<Trans>Volumes</Trans>}>
|
||||
{volumes.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{allowedCSIDrivers && (
|
||||
<DrawerItem name={<Trans>Allowed CSI Drivers</Trans>}>
|
||||
{allowedCSIDrivers.map(({ name }) => name).join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{allowedFlexVolumes && (
|
||||
<DrawerItem name={<Trans>Allowed Flex Volumes</Trans>}>
|
||||
{allowedFlexVolumes.map(({ driver }) => driver).join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{allowedProcMountTypes && (
|
||||
<DrawerItem name={<Trans>Allowed Proc Mount Types</Trans>}>
|
||||
{allowedProcMountTypes.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{allowedUnsafeSysctls && (
|
||||
<DrawerItem name={<Trans>Allowed Unsafe Sysctls</Trans>}>
|
||||
{allowedUnsafeSysctls.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{forbiddenSysctls && (
|
||||
<DrawerItem name={<Trans>Forbidden Sysctls</Trans>}>
|
||||
{forbiddenSysctls.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
<DrawerItem name={<Trans>Allow Privilege Escalation</Trans>}>
|
||||
{allowPrivilegeEscalation ? <Trans>Yes</Trans> : <Trans>No</Trans>}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Privileged</Trans>}>
|
||||
{privileged ? <Trans>Yes</Trans> : <Trans>No</Trans>}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Read-only Root Filesystem</Trans>}>
|
||||
{readOnlyRootFilesystem ? <Trans>Yes</Trans> : <Trans>No</Trans>}
|
||||
</DrawerItem>
|
||||
|
||||
{defaultAddCapabilities && (
|
||||
<DrawerItem name={<Trans>Default Add Capabilities</Trans>}>
|
||||
{defaultAddCapabilities.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{requiredDropCapabilities && (
|
||||
<DrawerItem name={<Trans>Required Drop Capabilities</Trans>}>
|
||||
{requiredDropCapabilities.join(", ")}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
<DrawerItem name={<Trans>Host IPC</Trans>}>
|
||||
{hostIPC ? <Trans>Yes</Trans> : <Trans>No</Trans>}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Host Network</Trans>}>
|
||||
{hostNetwork ? <Trans>Yes</Trans> : <Trans>No</Trans>}
|
||||
</DrawerItem>
|
||||
|
||||
<DrawerItem name={<Trans>Host PID</Trans>}>
|
||||
{hostPID ? <Trans>Yes</Trans> : <Trans>No</Trans>}
|
||||
</DrawerItem>
|
||||
|
||||
{hostPorts && (
|
||||
<DrawerItem name={<Trans>Host Ports (Min-Max)</Trans>} labelsOnly>
|
||||
{hostPorts.map(({ min, max }, index) => {
|
||||
return <Badge key={index} label={`${min} - ${max}`}/>
|
||||
})}
|
||||
</DrawerItem>
|
||||
)}
|
||||
|
||||
{allowedHostPaths && (
|
||||
<>
|
||||
<DrawerTitle title={<Trans>Allowed Host Paths</Trans>}/>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableCell><Trans>Path Prefix</Trans></TableCell>
|
||||
<TableCell><Trans>Read-only</Trans></TableCell>
|
||||
</TableHead>
|
||||
{allowedHostPaths.map(({ pathPrefix, readOnly }, index) => {
|
||||
return (
|
||||
<TableRow key={index}>
|
||||
<TableCell>{pathPrefix}</TableCell>
|
||||
<TableCell>{readOnly ? <Trans>Yes</Trans> : <Trans>No</Trans>}</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
})}
|
||||
</Table>
|
||||
</>
|
||||
)}
|
||||
|
||||
{this.renderRuleGroup(<Trans>Fs Group</Trans>, fsGroup)}
|
||||
{this.renderRuleGroup(<Trans>Run As Group</Trans>, runAsGroup)}
|
||||
{this.renderRuleGroup(<Trans>Run As User</Trans>, runAsUser)}
|
||||
{this.renderRuleGroup(<Trans>Supplemental Groups</Trans>, supplementalGroups)}
|
||||
|
||||
{runtimeClass && (
|
||||
<>
|
||||
<DrawerTitle title={<Trans>Runtime Class</Trans>}/>
|
||||
<DrawerItem name={<Trans>Allowed Runtime Class Names</Trans>}>
|
||||
{(runtimeClass.allowedRuntimeClassNames || []).join(", ") || "-"}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Default Runtime Class Name</Trans>}>
|
||||
{runtimeClass.defaultRuntimeClassName || "-"}
|
||||
</DrawerItem>
|
||||
</>
|
||||
)}
|
||||
|
||||
{seLinux && (
|
||||
<>
|
||||
<DrawerTitle title={<Trans>Se Linux</Trans>}/>
|
||||
<DrawerItem name={<Trans>Rule</Trans>}>
|
||||
{seLinux.rule}
|
||||
</DrawerItem>
|
||||
{seLinux.seLinuxOptions && (
|
||||
<>
|
||||
<DrawerItem name={<Trans>Level</Trans>}>
|
||||
{seLinux.seLinuxOptions.level}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Role</Trans>}>
|
||||
{seLinux.seLinuxOptions.role}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Type</Trans>}>
|
||||
{seLinux.seLinuxOptions.type}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>User</Trans>}>
|
||||
{seLinux.seLinuxOptions.user}
|
||||
</DrawerItem>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
apiManager.registerViews(pspApi, {
|
||||
Details: PodSecurityPolicyDetails,
|
||||
});
|
||||
Reference in new issue
Block a user