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 { KubeObject } from "../kube-object";
|
||||||
import { KubeApi } from "../kube-api";
|
import { KubeApi } from "../kube-api";
|
||||||
import type { KubeJsonApiData } from "../kube-json-api";
|
import type { KubeJsonApiData } from "../kube-json-api";
|
||||||
|
import { get } from "lodash";
|
||||||
|
|
||||||
export interface IEndpointPort {
|
export interface IEndpointPort {
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -63,6 +64,10 @@ export class EndpointAddress implements IEndpointAddress {
|
|||||||
resourceVersion: string;
|
resourceVersion: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static create(data: IEndpointAddress): EndpointAddress {
|
||||||
|
return new EndpointAddress(data);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(data: IEndpointAddress) {
|
constructor(data: IEndpointAddress) {
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
}
|
}
|
||||||
@ -90,35 +95,27 @@ export class EndpointSubset implements IEndpointSubset {
|
|||||||
ports: IEndpointPort[];
|
ports: IEndpointPort[];
|
||||||
|
|
||||||
constructor(data: IEndpointSubset) {
|
constructor(data: IEndpointSubset) {
|
||||||
Object.assign(this, data);
|
this.addresses = get(data, "addresses", []);
|
||||||
|
this.notReadyAddresses = get(data, "notReadyAddresses", []);
|
||||||
|
this.ports = get(data, "ports", []);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAddresses(): EndpointAddress[] {
|
getAddresses(): EndpointAddress[] {
|
||||||
const addresses = this.addresses || [];
|
return this.addresses.map(EndpointAddress.create);
|
||||||
|
|
||||||
return addresses.map(a => new EndpointAddress(a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getNotReadyAddresses(): EndpointAddress[] {
|
getNotReadyAddresses(): EndpointAddress[] {
|
||||||
const notReadyAddresses = this.notReadyAddresses || [];
|
return this.notReadyAddresses.map(EndpointAddress.create);
|
||||||
|
|
||||||
return notReadyAddresses.map(a => new EndpointAddress(a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string {
|
toString(): string {
|
||||||
if(!this.addresses) {
|
return this.addresses
|
||||||
return "";
|
.map(address => (
|
||||||
}
|
this.ports
|
||||||
|
.map(port => `${address.ip}:${port.port}`)
|
||||||
return this.addresses.map(address => {
|
.join(", ")
|
||||||
if (!this.ports) {
|
))
|
||||||
return address.ip;
|
.join(", ");
|
||||||
}
|
|
||||||
|
|
||||||
return this.ports.map(port => {
|
|
||||||
return `${address.ip}:${port.port}`;
|
|
||||||
}).join(", ");
|
|
||||||
}).join(", ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user