1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/+storage-volumes/volumes.store.ts
2022-04-06 10:34:16 -04:00

30 lines
1.0 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
import { autoBind } from "../../utils";
import type { PersistentVolume } from "../../../common/k8s-api/endpoints/persistent-volume.api";
import { persistentVolumeApi } from "../../../common/k8s-api/endpoints/persistent-volume.api";
import { apiManager } from "../../../common/k8s-api/api-manager";
import type { StorageClass } from "../../../common/k8s-api/endpoints/storage-class.api";
export class PersistentVolumesStore extends KubeObjectStore<PersistentVolume> {
api = persistentVolumeApi;
constructor() {
super();
autoBind(this);
}
getByStorageClass(storageClass: StorageClass): PersistentVolume[] {
return this.items.filter(volume =>
volume.getStorageClassName() === storageClass.getName(),
);
}
}
export const volumesStore = new PersistentVolumesStore();
apiManager.registerStore(volumesStore);