Feature 57 (config and provisioning): modules declare config and provisions, their files rendered from templates; synced with main (issues of feature 57, 874)

This commit is contained in:
2026-10-16 07:37:43 +00:00
parent 1a2c917abf
commit 9652b2d5ce
771 changed files with 52063 additions and 1774 deletions
@@ -73,7 +73,7 @@ func TestTheSessionsAreTheEntriesLemursOffersInItsOrder(t *testing.T) {
}
func TestTheModulesConfigurationIsReadAsLemursReadsIt(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("..", "..", "config", "config.toml"))
raw, err := os.ReadFile(filepath.Join("..", "..", "files", "config.toml"))
if err != nil {
t.Fatal(err)
}
@@ -93,11 +93,12 @@ func TestTheOfficialPackageAndItsServiceEnabledButNeverRestarted(t *testing.T) {
func TestTheConfigurationIsTheModulesFileAndOffersOnlyTheSessionsModulesPlace(t *testing.T) {
m := readManifest(t)
c := resource(t, m, "config")
raw, _ := os.ReadFile(filepath.Join("..", "..", "config", "config.toml"))
if c["path"] != "/etc/lemurs/config.toml" || c["content"] != string(raw) || c["into"] != nil {
t.Fatal("the manifest carries config/config.toml whole, as an owned file")
raw, _ := os.ReadFile(filepath.Join("..", "..", "files", "config.toml"))
if _, inline := c["content"]; inline || c["template"] != "files/config.toml" || len(raw) == 0 ||
c["path"] != "/etc/lemurs/config.toml" || c["into"] != nil {
t.Fatal("the manifest takes files/config.toml whole as its template, as an owned file")
}
text := c["content"].(string)
text := string(raw)
for _, want := range []string{"[x11]", "[wayland]", `xsetup_path = "/etc/lemurs/xsetup.sh"`, `scripts_path = "/etc/lemurs/wms"`,
`scripts_path = "/etc/lemurs/wayland"`, `xsessions_path = "/etc/lemurs/xsessions"`, `wayland_sessions_path = "/etc/lemurs/wayland-sessions"`,
`tty = 2`, `x11_display = ":1"`, `remember = true`} {
@@ -116,3 +117,31 @@ func TestTheConfigurationIsTheModulesFileAndOffersOnlyTheSessionsModulesPlace(t
}
}
}
// No file resource carries its text inline: each names its template in files/, and the build packs files/
// into the one archive the controller reads the templates back from (novox/hq ADR 0349 §2).
func TestEveryFileTakesItsTextFromATemplate(t *testing.T) {
m := readManifest(t)
for _, r := range m.Resources {
if _, inline := r["content"]; inline {
t.Errorf("resource %v keeps its text inline: keep it in files/ and name it as the template", r["id"])
}
if name, ok := r["template"].(string); ok {
if _, err := os.Stat(filepath.Join("..", "..", name)); err != nil {
t.Errorf("resource %v names %s: %v", r["id"], name, err)
}
}
}
packs := 0
for _, a := range m.Build.Artifacts {
if a["kind"] == "archive" && a["from"] == "files" {
packs++
if a["name"] != "files" {
t.Errorf("the templates archive is named %v, not files", a["name"])
}
}
}
if packs != 1 {
t.Errorf("the build packs files/ into %d archives, not one", packs)
}
}