mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: mount volumes on startup
This commit is contained in:
@@ -2,6 +2,7 @@ import type { BackendStatus } from "@ironmount/schemas";
|
||||
import type { Volume } from "../../db/schema";
|
||||
import { makeDirectoryBackend } from "./directory/directory-backend";
|
||||
import { makeNfsBackend } from "./nfs/nfs-backend";
|
||||
import { config } from "../../core/config";
|
||||
|
||||
export type VolumeBackend = {
|
||||
mount: () => Promise<void>;
|
||||
@@ -10,17 +11,17 @@ export type VolumeBackend = {
|
||||
};
|
||||
|
||||
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
||||
const { config, path } = volume;
|
||||
const path = `${config.volumeRootContainer}/${volume.name}/_data`;
|
||||
|
||||
switch (config.backend) {
|
||||
switch (volume.config.backend) {
|
||||
case "nfs": {
|
||||
return makeNfsBackend(config, path);
|
||||
return makeNfsBackend(volume.config, path);
|
||||
}
|
||||
case "directory": {
|
||||
return makeDirectoryBackend(config, path);
|
||||
return makeDirectoryBackend(volume.config, path);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Backend ${config.backend} not implemented`);
|
||||
throw new Error(`Backend ${volume.config.backend} not implemented`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user