feat(shellconfig): implement PlanForce

This commit is contained in:
MDietermann
2026-04-14 22:06:57 +02:00
parent 4ed257bbd1
commit b2cbd4f640
2 changed files with 54 additions and 2 deletions

View File

@@ -3,7 +3,6 @@ package shellconfig
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
@@ -91,5 +90,20 @@ func (m Module) Verify(ctx context.Context) error {
}
func (m Module) PlanForce(ctx context.Context) (module.Plan, error) {
return module.Plan{}, errors.New("PlanForce not implemented")
var actions []module.Action
for _, b := range m.cfg.Blocks {
b := b
actions = append(actions, module.Action{
Description: fmt.Sprintf("rewrite block %s into %s (force)", b.Name, b.File),
Kind: module.ActionFileWrite,
Exec: func(ctx context.Context) error {
p, err := resolveFile(b.File)
if err != nil {
return err
}
return platform.EnsureBlock(p, b.Name, b.Content)
},
})
}
return module.Plan{Actions: actions}, nil
}