mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Set defaults for EndpointSubsets
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
14b70a6c53
commit
94a23d2acb
@ -23,6 +23,7 @@ import { autoBind } from "../../utils";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import { get } from "lodash";
|
||||
|
||||
export interface IEndpointPort {
|
||||
name?: string;
|
||||
@ -63,6 +64,10 @@ export class EndpointAddress implements IEndpointAddress {
|
||||
resourceVersion: string;
|
||||
};
|
||||
|
||||
static create(data: IEndpointAddress): EndpointAddress {
|
||||
return new EndpointAddress(data);
|
||||
}
|
||||
|
||||
constructor(data: IEndpointAddress) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
@ -90,35 +95,27 @@ export class EndpointSubset implements IEndpointSubset {
|
||||
ports: IEndpointPort[];
|
||||
|
||||
constructor(data: IEndpointSubset) {
|
||||
Object.assign(this, data);
|
||||
this.addresses = get(data, "addresses", []);
|
||||
this.notReadyAddresses = get(data, "notReadyAddresses", []);
|
||||
this.ports = get(data, "ports", []);
|
||||
}
|
||||
|
||||
getAddresses(): EndpointAddress[] {
|
||||
const addresses = this.addresses || [];
|
||||
|
||||
return addresses.map(a => new EndpointAddress(a));
|
||||
return this.addresses.map(EndpointAddress.create);
|
||||
}
|
||||
|
||||
getNotReadyAddresses(): EndpointAddress[] {
|
||||
const notReadyAddresses = this.notReadyAddresses || [];
|
||||
|
||||
return notReadyAddresses.map(a => new EndpointAddress(a));
|
||||
return this.notReadyAddresses.map(EndpointAddress.create);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
if(!this.addresses) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.addresses.map(address => {
|
||||
if (!this.ports) {
|
||||
return address.ip;
|
||||
}
|
||||
|
||||
return this.ports.map(port => {
|
||||
return `${address.ip}:${port.port}`;
|
||||
}).join(", ");
|
||||
}).join(", ");
|
||||
return this.addresses
|
||||
.map(address => (
|
||||
this.ports
|
||||
.map(port => `${address.ip}:${port.port}`)
|
||||
.join(", ")
|
||||
))
|
||||
.join(", ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user