mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Factor out the filtering of condition types
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
15eb041378
commit
156cc406d3
@ -71,6 +71,15 @@ export function formatNodeTaint(taint: NodeTaint): string {
|
|||||||
return `${taint.key}:${taint.effect}`;
|
return `${taint.key}:${taint.effect}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface NodeCondition {
|
||||||
|
type: string;
|
||||||
|
status: string;
|
||||||
|
lastHeartbeatTime?: string;
|
||||||
|
lastTransitionTime?: string;
|
||||||
|
reason?: string;
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Node {
|
export interface Node {
|
||||||
spec: {
|
spec: {
|
||||||
podCIDR?: string;
|
podCIDR?: string;
|
||||||
@ -100,14 +109,7 @@ export interface Node {
|
|||||||
memory: string;
|
memory: string;
|
||||||
pods: string;
|
pods: string;
|
||||||
};
|
};
|
||||||
conditions?: {
|
conditions?: NodeCondition[];
|
||||||
type: string;
|
|
||||||
status: string;
|
|
||||||
lastHeartbeatTime?: string;
|
|
||||||
lastTransitionTime?: string;
|
|
||||||
reason?: string;
|
|
||||||
message?: string;
|
|
||||||
}[];
|
|
||||||
addresses?: {
|
addresses?: {
|
||||||
type: string;
|
type: string;
|
||||||
address: string;
|
address: string;
|
||||||
@ -141,6 +143,19 @@ export interface Node {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over `conditions` yielding the `type` field if the `status` field is
|
||||||
|
* the string `"True"`
|
||||||
|
* @param conditions An iterator of some conditions
|
||||||
|
*/
|
||||||
|
function* getTrueConditionTypes(conditions: IterableIterator<NodeCondition> | Iterable<NodeCondition>): IterableIterator<string> {
|
||||||
|
for (const { status, type } of conditions) {
|
||||||
|
if (status === "True") {
|
||||||
|
yield type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Node extends KubeObject {
|
export class Node extends KubeObject {
|
||||||
static kind = "Node";
|
static kind = "Node";
|
||||||
static namespaced = false;
|
static namespaced = false;
|
||||||
@ -151,17 +166,13 @@ export class Node extends KubeObject {
|
|||||||
autoBind(this);
|
autoBind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the concatination of all current condition types which have a status
|
||||||
|
* of `"True"`
|
||||||
|
*/
|
||||||
getNodeConditionText(): string {
|
getNodeConditionText(): string {
|
||||||
const { conditions = [] } = this.status;
|
|
||||||
|
|
||||||
return iter.join(
|
return iter.join(
|
||||||
iter.map(
|
getTrueConditionTypes(this.status?.conditions ?? []),
|
||||||
iter.filter(
|
|
||||||
conditions.values(),
|
|
||||||
({ status }) => status === "True",
|
|
||||||
),
|
|
||||||
({ type }) => type,
|
|
||||||
),
|
|
||||||
" ",
|
" ",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user