Refactored logic to use a map

Signed-off-by: Steve Richards <srichards@mirantis.com>
This commit is contained in:
Steve Richards committed 2020-10-13 18:17:33 +01:00
1 parent 6c9bf2f506
commit 82aae2946c
1 file changed
+5 -12
+5 -12
View File
@@ -2,7 +2,6 @@ import { KubeObject } from "../kube-object";
import { autobind } from "../../utils"; import { autobind } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api"; import { IMetrics, metricsApi } from "./metrics.api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { hostname } from "os";
export class IngressApi extends KubeApi<Ingress> { export class IngressApi extends KubeApi<Ingress> {
getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> { getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> {
@@ -110,17 +109,11 @@ export class Ingress extends KubeObject {
} }
getLoadBalancers() { getLoadBalancers() {
const ingressAddresses: string[] = []; const { status: { loadBalancer = { ingress: [] } } } = this;
const { status: { loadBalancer } } = this;
return (loadBalancer.ingress ?? []).map(address => (
if (!loadBalancer) return []; address.hostname || address.ip
))
loadBalancer.ingress.forEach(address => {
const entry = address.hostname ? address.hostname : address.ip;
ingressAddresses.push(entry);
})
return ingressAddresses;
} }
} }