mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Lens app source code (#119)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
936cbd53d4
commit
1d0815abd2
797 files changed
+73714
-215
No files matched your search
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
|
||||
loadMetrics(daemonSet: DaemonSet) {
|
||||
const pods = this.getChildPods(daemonSet);
|
||||
return podsApi.getMetrics(pods, daemonSet.getNs(), "").then(metrics =>
|
||||
this.metrics = metrics
|
||||
);
|
||||
}
|
||||
|
||||
getChildPods(daemonSet: DaemonSet): Pod[] {
|
||||
return podsStore.getPodsByOwner(daemonSet)
|
||||
}
|
||||
|
||||
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(daemonSetApi, daemonSetStore);
|
||||
Reference in new issue
Block a user