mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Return getPodsByOwner() method
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
43c743f298
commit
fc58fc868d
@ -4,6 +4,7 @@ import { KubeObjectStore } from "../../kube-object.store";
|
|||||||
import { autobind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
|
import { autobind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
|
||||||
import { IPodMetrics, Pod, PodMetrics, podMetricsApi, podsApi } from "../../api/endpoints";
|
import { IPodMetrics, Pod, PodMetrics, podMetricsApi, podsApi } from "../../api/endpoints";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class PodsStore extends KubeObjectStore<Pod> {
|
export class PodsStore extends KubeObjectStore<Pod> {
|
||||||
@ -31,6 +32,18 @@ export class PodsStore extends KubeObjectStore<Pod> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPodsByOwner(workload: WorkloadKubeObject): Pod[] {
|
||||||
|
if (!workload) return [];
|
||||||
|
|
||||||
|
return this.items.filter(pod => {
|
||||||
|
const owners = pod.getOwnerRefs();
|
||||||
|
|
||||||
|
if (!owners.length) return;
|
||||||
|
|
||||||
|
return owners.find(owner => owner.uid === workload.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getPodsByOwnerId(workloadId: string): Pod[] {
|
getPodsByOwnerId(workloadId: string): Pod[] {
|
||||||
return this.items.filter(pod => {
|
return this.items.filter(pod => {
|
||||||
return pod.getOwnerRefs().find(owner => owner.uid === workloadId);
|
return pod.getOwnerRefs().find(owner => owner.uid === workloadId);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user