Skip to content

Commit c2a4b02

Browse files
committed
feat: implement K8SLocalVolumeProvider and remove Metalk8sLocalVolumeProvider
1 parent a213f6f commit c2a4b02

File tree

2 files changed

+29
-37
lines changed

2 files changed

+29
-37
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { CoreV1Api, V1PersistentVolume } from '@kubernetes/client-node';
2+
import { Config } from '@kubernetes/client-node/dist/browser/config';
3+
4+
type LocalPersistentVolume = V1PersistentVolume & {
5+
IP: string;
6+
devicePath: string;
7+
};
8+
9+
interface K8SLocalVolumeAdapter {
10+
listLocalPersistentVolumes(): Promise<LocalPersistentVolume[]>;
11+
}
12+
13+
export default class K8SLocalVolumeProvider implements K8SLocalVolumeAdapter {
14+
k8sClient: CoreV1Api;
15+
constructor(url: string, token: string) {
16+
const config = new Config(url, token);
17+
this.k8sClient = config.makeApiClient(CoreV1Api);
18+
}
19+
public async listLocalPersistentVolumes(): Promise<LocalPersistentVolume[]> {
20+
try {
21+
// Fetch all local persistent volumes
22+
const pv = await this.k8sClient.listPersistentVolume();
23+
// MERGE with IP and devicePath
24+
return [];
25+
} catch (error) {
26+
// throw new Error(`Failed to fetch local persistent volumes: ${error.message}`);
27+
}
28+
}
29+
}

ui/src/services/k8s/Metalk8sLocalVolumeProvider.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)