refactor: docker volume prefix

This commit is contained in:
Nicolas Meienberger
2025-09-27 14:49:22 +02:00
parent 88e310cc4f
commit aa32ea322d
8 changed files with 29 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
import { Hono } from "hono";
import { VOLUME_MOUNT_BASE } from "~/core/constants";
import { volumeService } from "../volumes/volume.service";
import { config } from "../../core/config";
export const driverController = new Hono()
.post("/VolumeDriver.Capabilities", (c) => {
@@ -30,8 +30,9 @@ export const driverController = new Hono()
return c.json({ Err: "Volume name is required" }, 400);
}
const volumeRoot = config.volumeRootHost;
const mountpoint = `${volumeRoot}/${body.Name}/_data`;
const volumeName = body.Name.replace(/^im-/, "");
const mountpoint = `${VOLUME_MOUNT_BASE}/${volumeName}/_data`;
return c.json({
Mountpoint: mountpoint,
@@ -54,13 +55,12 @@ export const driverController = new Hono()
return c.json({ Err: "Volume name is required" }, 400);
}
const volumeRoot = config.volumeRootHost;
const { volume } = await volumeService.getVolume(body.Name);
const { volume } = await volumeService.getVolume(body.Name.replace(/^im-/, ""));
return c.json({
Volume: {
Name: volume.name,
Mountpoint: `${volumeRoot}/${volume.name}/_data`,
Name: `im-${volume.name}`,
Mountpoint: `${VOLUME_MOUNT_BASE}/${volume.name}/_data`,
Status: {},
},
Err: "",
@@ -68,11 +68,10 @@ export const driverController = new Hono()
})
.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`,
Name: `im-${volume.name}`,
Mountpoint: `${VOLUME_MOUNT_BASE}/${volume.name}/_data`,
Status: {},
}));