move to correct structure

This commit is contained in:
JOLIMAITRE Matthieu 2023-12-09 00:08:48 +01:00
parent 44825c4c31
commit 54c4e91af8
12 changed files with 118 additions and 1 deletions

View file

@ -1,21 +0,0 @@
import { container_paths } from "./paths.ts";
import { exists } from "./utils.ts";
export type ContainerConfig = ReturnType<typeof new_container_config>;
export function new_container_config(name: string) {
return {
name,
version: 0,
redirects: [] as [number, number][],
};
}
export async function load_container_config(name: string) {
const config_path = container_paths(name).config;
if (!exists(config_path)) return null;
const content = await Deno.readTextFile(config_path);
const read = JSON.parse(content);
const default_ = new_container_config(name);
if (read.version < default_.version) throw new Error("read conf version is outdated");
return { ...default_, ...read };
}