mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Adding LogTabStore Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding Pod selector in logs tab Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Refresh containers on pod change Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding <LogResourceSelector /> tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding LogTabStore tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Clearn getPodsByOwnerId method Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Extracting dummy pods into mock file Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Eliminating containers and initContainers from store Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Refreshing tab pods if pod amount is changed in store Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * A bit of cleaning up, fixing tests Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix lint newline errors Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Return getPodsByOwner() method Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Rename log tab when pod changes Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { observable } from "mobx";
|
|
import { KubeObjectStore } from "../../kube-object.store";
|
|
import { autobind } from "../../utils";
|
|
import { DaemonSet, daemonSetApi, IPodMetrics, Pod, podsApi, PodStatus } from "../../api/endpoints";
|
|
import { podsStore } from "../+workloads-pods/pods.store";
|
|
import { apiManager } from "../../api/api-manager";
|
|
|
|
@autobind()
|
|
export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
|
|
api = daemonSetApi;
|
|
|
|
@observable metrics: IPodMetrics = null;
|
|
|
|
async loadMetrics(daemonSet: DaemonSet) {
|
|
const pods = this.getChildPods(daemonSet);
|
|
|
|
this.metrics = await podsApi.getMetrics(pods, daemonSet.getNs(), "");
|
|
}
|
|
|
|
getChildPods(daemonSet: DaemonSet): Pod[] {
|
|
return podsStore.getPodsByOwnerId(daemonSet.getId());
|
|
}
|
|
|
|
getStatuses(daemonSets?: DaemonSet[]) {
|
|
const status = { failed: 0, pending: 0, running: 0 };
|
|
|
|
daemonSets.forEach(daemonSet => {
|
|
const pods = this.getChildPods(daemonSet);
|
|
|
|
if (pods.some(pod => pod.getStatus() === PodStatus.FAILED)) {
|
|
status.failed++;
|
|
}
|
|
else if (pods.some(pod => pod.getStatus() === PodStatus.PENDING)) {
|
|
status.pending++;
|
|
}
|
|
else {
|
|
status.running++;
|
|
}
|
|
});
|
|
|
|
return status;
|
|
}
|
|
|
|
reset() {
|
|
this.metrics = null;
|
|
}
|
|
}
|
|
|
|
export const daemonSetStore = new DaemonSetStore();
|
|
apiManager.registerStore(daemonSetStore);
|