mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Enforce semicolons in eslint
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
1 parent
0f3f5611ba
commit
1477bb8274
531 files changed
+3979
-3975
No files matched your search
@@ -101,4 +101,4 @@ export const ContainerCharts = observer(() => {
|
||||
data={{ datasets: datasets[tabId] }}
|
||||
/>
|
||||
);
|
||||
})
|
||||
});
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./pods"
|
||||
export * from "./pod-details"
|
||||
export * from "./pods";
|
||||
export * from "./pod-details";
|
||||
@@ -128,4 +128,4 @@ export const PodCharts = observer(() => {
|
||||
data={{ datasets: datasets[tabId] }}
|
||||
/>
|
||||
);
|
||||
})
|
||||
});
|
||||
@@ -18,42 +18,42 @@ interface Props {
|
||||
}
|
||||
|
||||
export const ContainerEnvironment = observer((props: Props) => {
|
||||
const { container: { env, envFrom }, namespace } = props
|
||||
const { container: { env, envFrom }, namespace } = props;
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
autorun(() => {
|
||||
env && env.forEach(variable => {
|
||||
const { valueFrom } = variable
|
||||
const { valueFrom } = variable;
|
||||
if (valueFrom && valueFrom.configMapKeyRef) {
|
||||
configMapsStore.load({ name: valueFrom.configMapKeyRef.name, namespace })
|
||||
configMapsStore.load({ name: valueFrom.configMapKeyRef.name, namespace });
|
||||
}
|
||||
})
|
||||
});
|
||||
envFrom && envFrom.forEach(item => {
|
||||
const { configMapRef } = item
|
||||
const { configMapRef } = item;
|
||||
if (configMapRef && configMapRef.name) {
|
||||
configMapsStore.load({ name: configMapRef.name, namespace })
|
||||
configMapsStore.load({ name: configMapRef.name, namespace });
|
||||
}
|
||||
})
|
||||
});
|
||||
}),
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
const renderEnv = () => {
|
||||
const orderedEnv = _.sortBy(env, 'name');
|
||||
|
||||
return orderedEnv.map(variable => {
|
||||
const { name, value, valueFrom } = variable
|
||||
let secretValue = null
|
||||
const { name, value, valueFrom } = variable;
|
||||
let secretValue = null;
|
||||
|
||||
if (value) {
|
||||
secretValue = value
|
||||
secretValue = value;
|
||||
}
|
||||
if (valueFrom) {
|
||||
const { fieldRef, secretKeyRef, configMapKeyRef } = valueFrom
|
||||
const { fieldRef, secretKeyRef, configMapKeyRef } = valueFrom;
|
||||
if (fieldRef) {
|
||||
const { apiVersion, fieldPath } = fieldRef
|
||||
secretValue = `fieldRef(${apiVersion}:${fieldPath})`
|
||||
const { apiVersion, fieldPath } = fieldRef;
|
||||
secretValue = `fieldRef(${apiVersion}:${fieldPath})`;
|
||||
}
|
||||
if (secretKeyRef) {
|
||||
secretValue = (
|
||||
@@ -61,14 +61,14 @@ export const ContainerEnvironment = observer((props: Props) => {
|
||||
reference={secretKeyRef}
|
||||
namespace={namespace}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
if (configMapKeyRef) {
|
||||
const { name, key } = configMapKeyRef
|
||||
const configMap = configMapsStore.getByName(name, namespace)
|
||||
const { name, key } = configMapKeyRef;
|
||||
const configMap = configMapsStore.getByName(name, namespace);
|
||||
secretValue = configMap ?
|
||||
configMap.data[key] :
|
||||
`configMapKeyRef(${name}${key})`
|
||||
`configMapKeyRef(${name}${key})`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,31 +76,31 @@ export const ContainerEnvironment = observer((props: Props) => {
|
||||
<div className="variable" key={name}>
|
||||
<span className="var-name">{name}</span>: {secretValue}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const renderEnvFrom = () => {
|
||||
const envVars = envFrom.map(vars => {
|
||||
if (!vars.configMapRef || !vars.configMapRef.name) return
|
||||
const configMap = configMapsStore.getByName(vars.configMapRef.name, namespace)
|
||||
if (!configMap) return
|
||||
if (!vars.configMapRef || !vars.configMapRef.name) return;
|
||||
const configMap = configMapsStore.getByName(vars.configMapRef.name, namespace);
|
||||
if (!configMap) return;
|
||||
return Object.entries(configMap.data).map(([name, value]) => (
|
||||
<div className="variable" key={name}>
|
||||
<span className="var-name">{name}</span>: {value}
|
||||
</div>
|
||||
))
|
||||
})
|
||||
return _.flatten(envVars)
|
||||
}
|
||||
));
|
||||
});
|
||||
return _.flatten(envVars);
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerItem name={<Trans>Environment</Trans>} className="ContainerEnvironment">
|
||||
{env && renderEnv()}
|
||||
{envFrom && renderEnvFrom()}
|
||||
</DrawerItem>
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
interface SecretKeyProps {
|
||||
reference: {
|
||||
@@ -111,20 +111,20 @@ interface SecretKeyProps {
|
||||
}
|
||||
|
||||
const SecretKey = (props: SecretKeyProps) => {
|
||||
const { reference: { name, key }, namespace } = props
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [secret, setSecret] = useState<Secret>()
|
||||
const { reference: { name, key }, namespace } = props;
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [secret, setSecret] = useState<Secret>();
|
||||
|
||||
const showKey = async (evt: React.MouseEvent) => {
|
||||
evt.preventDefault()
|
||||
setLoading(true)
|
||||
evt.preventDefault();
|
||||
setLoading(true);
|
||||
const secret = await secretsStore.load({ name, namespace });
|
||||
setLoading(false)
|
||||
setSecret(secret)
|
||||
}
|
||||
setLoading(false);
|
||||
setSecret(secret);
|
||||
};
|
||||
|
||||
if (secret?.data?.[key]) {
|
||||
return <>{base64.decode(secret.data[key])}</>
|
||||
return <>{base64.decode(secret.data[key])}</>;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -137,5 +137,5 @@ const SecretKey = (props: SecretKeyProps) => {
|
||||
onClick={showKey}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -1,15 +1,15 @@
|
||||
import "./pod-container-port.scss"
|
||||
import "./pod-container-port.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { t } from "@lingui/macro";
|
||||
import { Pod, IPodContainer } from "../../api/endpoints";
|
||||
import { _i18n } from "../../i18n";
|
||||
import { apiBase } from "../../api"
|
||||
import { apiBase } from "../../api";
|
||||
import { observable } from "mobx";
|
||||
import { cssNames } from "../../utils";
|
||||
import { Notifications } from "../notifications";
|
||||
import { Spinner } from "../spinner"
|
||||
import { Spinner } from "../spinner";
|
||||
|
||||
interface Props {
|
||||
pod: Pod;
|
||||
@@ -28,7 +28,7 @@ export class PodContainerPort extends React.Component<Props> {
|
||||
const { pod, port } = this.props;
|
||||
this.waiting = true;
|
||||
try {
|
||||
await apiBase.post(`/pods/${pod.getNs()}/pod/${pod.getName()}/port-forward/${port.containerPort}`, {})
|
||||
await apiBase.post(`/pods/${pod.getNs()}/pod/${pod.getName()}/port-forward/${port.containerPort}`, {});
|
||||
} catch(error) {
|
||||
Notifications.error(error);
|
||||
} finally {
|
||||
@@ -39,7 +39,7 @@ export class PodContainerPort extends React.Component<Props> {
|
||||
render() {
|
||||
const { port } = this.props;
|
||||
const { name, containerPort, protocol } = port;
|
||||
const text = (name ? name + ': ' : '')+`${containerPort}/${protocol}`
|
||||
const text = (name ? name + ': ' : '')+`${containerPort}/${protocol}`;
|
||||
return (
|
||||
<div className={cssNames("PodContainerPort", { waiting: this.waiting })}>
|
||||
<span title={_i18n._(t`Open in a browser`)} onClick={() => this.portForward() }>
|
||||
@@ -49,6 +49,6 @@ export class PodContainerPort extends React.Component<Props> {
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ interface Props {
|
||||
|
||||
export class PodDetailsAffinities extends React.Component<Props> {
|
||||
render() {
|
||||
const { workload } = this.props
|
||||
const affinitiesNum = workload.getAffinityNumber()
|
||||
const affinities = workload.getAffinity()
|
||||
if (!affinitiesNum) return null
|
||||
const { workload } = this.props;
|
||||
const affinitiesNum = workload.getAffinityNumber();
|
||||
const affinities = workload.getAffinity();
|
||||
if (!affinitiesNum) return null;
|
||||
return (
|
||||
<DrawerItem name={<Trans>Affinities</Trans>} className="PodDetailsAffinities">
|
||||
<DrawerParamToggler label={affinitiesNum}>
|
||||
@@ -29,6 +29,6 @@ export class PodDetailsAffinities extends React.Component<Props> {
|
||||
</div>
|
||||
</DrawerParamToggler>
|
||||
</DrawerItem>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import "./pod-details-container.scss"
|
||||
import "./pod-details-container.scss";
|
||||
|
||||
import React from "react";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
@@ -23,7 +23,7 @@ interface Props {
|
||||
export class PodDetailsContainer extends React.Component<Props> {
|
||||
|
||||
renderStatus(state: string, status: IPodContainerStatus) {
|
||||
const ready = status ? status.ready : ""
|
||||
const ready = status ? status.ready : "";
|
||||
return (
|
||||
<span className={cssNames("status", state)}>
|
||||
{state}{ready ? `, ${_i18n._(t`ready`)}` : ""}
|
||||
@@ -41,20 +41,20 @@ export class PodDetailsContainer extends React.Component<Props> {
|
||||
{_i18n._(t`Started at`)}: {status.lastState.terminated.startedAt}<br/>
|
||||
{_i18n._(t`Finished at`)}: {status.lastState.terminated.finishedAt}<br/>
|
||||
</span>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { pod, container, metrics } = this.props
|
||||
if (!pod || !container) return null
|
||||
const { name, image, imagePullPolicy, ports, volumeMounts, command, args } = container
|
||||
const status = pod.getContainerStatuses().find(status => status.name === container.name)
|
||||
const state = status ? Object.keys(status.state)[0] : ""
|
||||
const lastState = status ? Object.keys(status.lastState)[0] : ""
|
||||
const ready = status ? status.ready : ""
|
||||
const liveness = pod.getLivenessProbe(container)
|
||||
const readiness = pod.getReadinessProbe(container)
|
||||
const { pod, container, metrics } = this.props;
|
||||
if (!pod || !container) return null;
|
||||
const { name, image, imagePullPolicy, ports, volumeMounts, command, args } = container;
|
||||
const status = pod.getContainerStatuses().find(status => status.name === container.name);
|
||||
const state = status ? Object.keys(status.state)[0] : "";
|
||||
const lastState = status ? Object.keys(status.lastState)[0] : "";
|
||||
const ready = status ? status.ready : "";
|
||||
const liveness = pod.getLivenessProbe(container);
|
||||
const readiness = pod.getReadinessProbe(container);
|
||||
const isInitContainer = !!pod.getInitContainers().find(c => c.name == name);
|
||||
const metricTabs = [
|
||||
<Trans>CPU</Trans>,
|
||||
@@ -93,10 +93,10 @@ export class PodDetailsContainer extends React.Component<Props> {
|
||||
<DrawerItem name={<Trans>Ports</Trans>}>
|
||||
{
|
||||
ports.map((port) => {
|
||||
const key = `${container.name}-port-${port.containerPort}-${port.protocol}`
|
||||
const key = `${container.name}-port-${port.containerPort}-${port.protocol}`;
|
||||
return(
|
||||
<PodContainerPort pod={pod} port={port} key={key}/>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</DrawerItem>
|
||||
@@ -112,7 +112,7 @@ export class PodDetailsContainer extends React.Component<Props> {
|
||||
<span className="mount-path">{mountPath}</span>
|
||||
<span className="mount-from">from {name} ({readOnly ? 'ro' : 'rw'})</span>
|
||||
</React.Fragment>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</DrawerItem>
|
||||
@@ -147,6 +147,6 @@ export class PodDetailsContainer extends React.Component<Props> {
|
||||
</DrawerItem>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export class PodDetailsList extends React.Component<Props> {
|
||||
this.metricsWatcher.start(true);
|
||||
disposeOnUnmount(this, [
|
||||
reaction(() => this.props.owner, () => this.metricsWatcher.restart(true))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -10,9 +10,9 @@ interface Props {
|
||||
|
||||
export class PodDetailsStatuses extends React.Component<Props> {
|
||||
render() {
|
||||
const { pods } = this.props
|
||||
if (!pods.length) return null
|
||||
const statuses = countBy(pods.map(pod => pod.getStatus()))
|
||||
const { pods } = this.props;
|
||||
if (!pods.length) return null;
|
||||
const statuses = countBy(pods.map(pod => pod.getStatus()));
|
||||
return (
|
||||
<div className="PodDetailsStatuses">
|
||||
{
|
||||
@@ -23,6 +23,6 @@ export class PodDetailsStatuses extends React.Component<Props> {
|
||||
))
|
||||
}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -10,15 +10,15 @@ interface Props {
|
||||
|
||||
export class PodDetailsTolerations extends React.Component<Props> {
|
||||
render() {
|
||||
const { workload } = this.props
|
||||
const tolerations = workload.getTolerations()
|
||||
if (!tolerations.length) return null
|
||||
const { workload } = this.props;
|
||||
const tolerations = workload.getTolerations();
|
||||
if (!tolerations.length) return null;
|
||||
return (
|
||||
<DrawerItem name={<Trans>Tolerations</Trans>} className="PodDetailsTolerations">
|
||||
<DrawerParamToggler label={tolerations.length}>
|
||||
{
|
||||
tolerations.map((toleration, index) => {
|
||||
const { key, operator, effect, tolerationSeconds } = toleration
|
||||
const { key, operator, effect, tolerationSeconds } = toleration;
|
||||
return (
|
||||
<div className="toleration" key={index}>
|
||||
<DrawerItem name={<Trans>Key</Trans>}>{key}</DrawerItem>
|
||||
@@ -26,11 +26,11 @@ export class PodDetailsTolerations extends React.Component<Props> {
|
||||
{effect && <DrawerItem name={<Trans>Effect</Trans>}>{effect}</DrawerItem>}
|
||||
{!!tolerationSeconds && <DrawerItem name={<Trans>Effect</Trans>}>{tolerationSeconds}</DrawerItem>}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</DrawerParamToggler>
|
||||
</DrawerItem>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import "./pod-details.scss"
|
||||
import "./pod-details.scss";
|
||||
|
||||
import React from "react";
|
||||
import kebabCase from "lodash/kebabCase";
|
||||
@@ -106,7 +106,7 @@ export class PodDetails extends React.Component<Props> {
|
||||
className={cssNames({ disabled: status === "False" })}
|
||||
tooltip={<Trans>Last transition time: {lastTransitionTime}</Trans>}
|
||||
/>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</DrawerItem>
|
||||
@@ -134,7 +134,7 @@ export class PodDetails extends React.Component<Props> {
|
||||
}
|
||||
{
|
||||
pod.getInitContainers() && pod.getInitContainers().map(container => {
|
||||
return <PodDetailsContainer key={container.name} pod={pod} container={container}/>
|
||||
return <PodDetailsContainer key={container.name} pod={pod} container={container}/>;
|
||||
})
|
||||
}
|
||||
<DrawerTitle title={<Trans>Containers</Trans>}/>
|
||||
@@ -149,7 +149,7 @@ export class PodDetails extends React.Component<Props> {
|
||||
container={container}
|
||||
metrics={metrics}
|
||||
/>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ export class PodDetails extends React.Component<Props> {
|
||||
{volumes.map(volume => {
|
||||
const claimName = volume.persistentVolumeClaim ? volume.persistentVolumeClaim.claimName : null;
|
||||
const configMap = volume.configMap ? volume.configMap.name : null;
|
||||
const type = Object.keys(volume)[1]
|
||||
const type = Object.keys(volume)[1];
|
||||
|
||||
return (
|
||||
<div key={volume.name} className="volume">
|
||||
@@ -211,12 +211,12 @@ export class PodDetails extends React.Component<Props> {
|
||||
</DrawerItem>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ kubeObjectDetailRegistry.add({
|
||||
components: {
|
||||
Details: (props: KubeObjectDetailsProps<Pod>) => <PodDetails {...props} />
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
kubeObjectDetailRegistry.add({
|
||||
kind: "Pod",
|
||||
@@ -235,4 +235,4 @@ kubeObjectDetailRegistry.add({
|
||||
components: {
|
||||
Details: (props: KubeObjectDetailsProps<Pod>) => <KubeEventDetails {...props} />
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -30,19 +30,19 @@ export class PodsStore extends KubeObjectStore<Pod> {
|
||||
getPodsByOwner(workload: WorkloadKubeObject): Pod[] {
|
||||
if (!workload) return [];
|
||||
return this.items.filter(pod => {
|
||||
const owners = pod.getOwnerRefs()
|
||||
if (!owners.length) return
|
||||
return owners.find(owner => owner.uid === workload.getId())
|
||||
})
|
||||
const owners = pod.getOwnerRefs();
|
||||
if (!owners.length) return;
|
||||
return owners.find(owner => owner.uid === workload.getId());
|
||||
});
|
||||
}
|
||||
|
||||
getPodsByNode(node: string) {
|
||||
if (!this.isLoaded) return []
|
||||
return this.items.filter(pod => pod.spec.nodeName === node)
|
||||
if (!this.isLoaded) return [];
|
||||
return this.items.filter(pod => pod.spec.nodeName === node);
|
||||
}
|
||||
|
||||
getStatuses(pods: Pod[]) {
|
||||
return countBy(pods.map(pod => pod.getStatus()))
|
||||
return countBy(pods.map(pod => pod.getStatus()));
|
||||
}
|
||||
|
||||
getPodKubeMetrics(pod: Pod) {
|
||||
@@ -57,16 +57,16 @@ export class PodsStore extends KubeObjectStore<Pod> {
|
||||
if (!metrics) return empty;
|
||||
return containers.reduce((total, container) => {
|
||||
const metric = metrics.containers.find(item => item.name == container.name);
|
||||
let cpu = "0"
|
||||
let memory = "0"
|
||||
let cpu = "0";
|
||||
let memory = "0";
|
||||
if (metric && metric.usage) {
|
||||
cpu = metric.usage.cpu || "0"
|
||||
memory = metric.usage.memory || "0"
|
||||
cpu = metric.usage.cpu || "0";
|
||||
memory = metric.usage.memory || "0";
|
||||
}
|
||||
return {
|
||||
cpu: total.cpu + cpuUnitsToNumber(cpu),
|
||||
memory: total.memory + unitsToBytes(memory)
|
||||
}
|
||||
};
|
||||
}, empty);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "./pods.scss"
|
||||
import "./pods.scss";
|
||||
|
||||
import React, { Fragment } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
@@ -64,7 +64,7 @@ export class Pods extends React.Component<Props> {
|
||||
}}
|
||||
/>
|
||||
</Fragment>
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,13 +113,13 @@ export class Pods extends React.Component<Props> {
|
||||
<Link key={name} to={detailsLink} className="owner" onClick={stopPropagation}>
|
||||
{kind}
|
||||
</Link>
|
||||
)
|
||||
);
|
||||
}),
|
||||
pod.getQosClass(),
|
||||
pod.getAge(),
|
||||
{ title: pod.getStatusMessage(), className: kebabCase(pod.getStatusMessage()) }
|
||||
]}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user