mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { observable } from "mobx";
|
|
import { autobind } from "../../utils";
|
|
import { KubeObjectStore } from "../../kube-object.store";
|
|
import { Deployment, IPodMetrics, podsApi, ReplicaSet, replicaSetApi } from "../../api/endpoints";
|
|
import { podsStore } from "../+workloads-pods/pods.store";
|
|
import { apiManager } from "../../api/api-manager";
|
|
|
|
@autobind()
|
|
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
|
|
api = replicaSetApi
|
|
@observable metrics: IPodMetrics = null;
|
|
|
|
loadMetrics(replicaSet: ReplicaSet) {
|
|
const pods = this.getChildPods(replicaSet);
|
|
return podsApi.getMetrics(pods, replicaSet.getNs(), "").then(metrics =>
|
|
this.metrics = metrics
|
|
);
|
|
}
|
|
|
|
getChildPods(replicaSet: ReplicaSet) {
|
|
return podsStore.getPodsByOwner(replicaSet);
|
|
}
|
|
|
|
getReplicaSetsByOwner(deployment: Deployment) {
|
|
return this.items.filter(replicaSet =>
|
|
!!replicaSet.getOwnerRefs().find(owner => owner.uid === deployment.getId())
|
|
)
|
|
}
|
|
|
|
reset() {
|
|
this.metrics = null;
|
|
}
|
|
}
|
|
|
|
export const replicaSetStore = new ReplicaSetStore();
|
|
apiManager.registerStore(replicaSetApi, replicaSetStore);
|