disko2: Implement rudimentary generate mode

Error handling could be done better, but I'm pretty happy with it
already.
The important part is aggregating all errors instead of failing on the
first issue we encounter.
This commit is contained in:
Felix Uhl committed 2024-10-30 19:35:51 +01:00
1 parent 8acd24950d
commit e825c64c8d
8 files changed
+337 -4

No files matched your search

+3 -2
View File
@@ -8,6 +8,7 @@ from typing import Any, Literal
from lib.eval_config import eval_disko_file, eval_flake
from lib.logging import LOGGER, debug, info
from lib.result import DiskoError, DiskoSuccess, DiskoResult, exit_on_error
from lib.types.disk import generate_config
Mode = Literal[
"destroy", "format", "mount", "destroy,format,mount", "format,mount", "generate"
@@ -48,8 +49,8 @@ def run_apply(
return DiskoError.single_message("ERR_TOO_MANY_ARGUMENTS", {}, "validate args")
def run_generate() -> DiskoResult[Literal["generate"]]:
return DiskoSuccess("generate", "generate config")
def run_generate() -> DiskoResult[dict[str, Any]]:
return generate_config()
def run(