feat: drop-in support for custom templates
User templates can now be added without rebuilding: drop a script into ~/.config/motd-assist/templates/ and reference it from a preset via "install": "<filename>". Same-name files override built-ins; new files are picked up by the running TUI via 'r'. `motd-assist templates` lists known templates and creates the drop-in directory. Apply plans now embed the resolved template content (Plan.ResolveContents) so the sudo/root process never needs to read user config; snapshots store installed script content so restore works under sudo as well. Validation rejects plans with unresolved content.
This commit is contained in:
parent
d56659e21a
commit
303c49b484
10 changed files with 375 additions and 48 deletions
|
|
@ -33,6 +33,9 @@ func TestExecuteAppliesPlanAndRestore(t *testing.T) {
|
|||
if plan.Empty() {
|
||||
t.Fatal("Plan sollte Änderungen enthalten")
|
||||
}
|
||||
if err := plan.ResolveContents(); err != nil {
|
||||
t.Fatalf("ResolveContents: %v", err)
|
||||
}
|
||||
if err := Execute(root, plan); err != nil {
|
||||
t.Fatalf("Execute: %v", err)
|
||||
}
|
||||
|
|
@ -93,7 +96,11 @@ func TestExecuteInstallAndRemove(t *testing.T) {
|
|||
{Name: "00-header", Enabled: true},
|
||||
{Name: "95-footer", Remove: true},
|
||||
}
|
||||
if err := Execute(root, Diff(current, desired)); err != nil {
|
||||
plan := Diff(current, desired)
|
||||
if err := plan.ResolveContents(); err != nil {
|
||||
t.Fatalf("ResolveContents: %v", err)
|
||||
}
|
||||
if err := Execute(root, plan); err != nil {
|
||||
t.Fatalf("Execute: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue