1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Refactored logic to use a map

Signed-off-by: Steve Richards <srichards@mirantis.com>
This commit is contained in:
Steve Richards 2020-10-13 16:36:43 +01:00
parent 6c9bf2f506
commit 82aae2946c

View File

@ -2,7 +2,6 @@ import { KubeObject } from "../kube-object";
import { autobind } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api";
import { KubeApi } from "../kube-api";
import { hostname } from "os";
export class IngressApi extends KubeApi<Ingress> {
getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> {
@ -110,17 +109,11 @@ export class Ingress extends KubeObject {
}
getLoadBalancers() {
const ingressAddresses: string[] = [];
const { status: { loadBalancer } } = this;
if (!loadBalancer) return [];
loadBalancer.ingress.forEach(address => {
const entry = address.hostname ? address.hostname : address.ip;
ingressAddresses.push(entry);
})
return ingressAddresses;
const { status: { loadBalancer = { ingress: [] } } } = this;
return (loadBalancer.ingress ?? []).map(address => (
address.hostname || address.ip
))
}
}