mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: implement driver
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
import { volumeService } from "../volumes/volume.service";
|
||||||
|
import { config } from "../../core/config";
|
||||||
|
|
||||||
export const driverController = new Hono()
|
export const driverController = new Hono()
|
||||||
.post("/VolumeDriver.Capabilities", (c) => {
|
.post("/VolumeDriver.Capabilities", (c) => {
|
||||||
@@ -13,10 +15,8 @@ export const driverController = new Hono()
|
|||||||
Implements: ["VolumeDriver"],
|
Implements: ["VolumeDriver"],
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.post("/VolumeDriver.Create", (c) => {
|
.post("/VolumeDriver.Create", (_) => {
|
||||||
return c.json({
|
throw new Error("Volume creation is not supported via the driver");
|
||||||
Err: "",
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.post("/VolumeDriver.Remove", (c) => {
|
.post("/VolumeDriver.Remove", (c) => {
|
||||||
return c.json({
|
return c.json({
|
||||||
@@ -38,21 +38,36 @@ export const driverController = new Hono()
|
|||||||
Mountpoint: `/mnt/something`,
|
Mountpoint: `/mnt/something`,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.post("/VolumeDriver.Get", (c) => {
|
.post("/VolumeDriver.Get", async (c) => {
|
||||||
|
const body = await c.req.json();
|
||||||
|
|
||||||
|
if (!body.Name) {
|
||||||
|
return c.json({ Err: "Volume name is required" }, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
const volumeRoot = config.volumeRootHost;
|
||||||
|
const { volume } = await volumeService.getVolume(body.Name);
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
Name: "my-volume",
|
Volume: {
|
||||||
Mountpoint: `/mnt/something`,
|
Name: volume.name,
|
||||||
Status: {},
|
Mountpoint: `${volumeRoot}/${volume.name}/_data`,
|
||||||
|
Status: {},
|
||||||
|
},
|
||||||
|
Err: "",
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.post("/VolumeDriver.List", (c) => {
|
.post("/VolumeDriver.List", async (c) => {
|
||||||
|
const volumes = await volumeService.listVolumes();
|
||||||
|
const volumeRoot = config.volumeRootHost;
|
||||||
|
|
||||||
|
const res = volumes.map((volume) => ({
|
||||||
|
Name: volume.name,
|
||||||
|
Mountpoint: `${volumeRoot}/${volume.name}/_data`,
|
||||||
|
Status: {},
|
||||||
|
}));
|
||||||
|
|
||||||
return c.json({
|
return c.json({
|
||||||
Volumes: [
|
Volumes: res,
|
||||||
{
|
|
||||||
Name: "my-volume",
|
|
||||||
Mountpoint: `/mnt/something`,
|
|
||||||
Status: {},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user