feat(shellconfig): implement PlanForce
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user