do: verify the action exists before running
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
32
plan/plan.go
32
plan/plan.go
@@ -175,17 +175,19 @@ func (p *Plan) fillAction() {
|
||||
noOpRunner,
|
||||
)
|
||||
|
||||
actions := p.source.LookupPath(cue.MakePath(ActionSelector))
|
||||
actionsComment := ""
|
||||
for _, cg := range actions.Doc() {
|
||||
actionsComment += cg.Text()
|
||||
}
|
||||
p.action = &Action{
|
||||
ActionSelector.String(),
|
||||
false,
|
||||
actions.Path(),
|
||||
actionsComment,
|
||||
[]*Action{},
|
||||
Name: ActionSelector.String(),
|
||||
Hidden: false,
|
||||
Path: cue.MakePath(ActionSelector),
|
||||
Children: []*Action{},
|
||||
}
|
||||
|
||||
actions := p.source.LookupPath(cue.MakePath(ActionSelector))
|
||||
if actions.Exists() {
|
||||
return
|
||||
}
|
||||
for _, cg := range actions.Doc() {
|
||||
p.action.Comment += cg.Text()
|
||||
}
|
||||
|
||||
tasks := flow.Tasks()
|
||||
@@ -205,11 +207,11 @@ func (p *Plan) fillAction() {
|
||||
}
|
||||
|
||||
a = &Action{
|
||||
s.String(),
|
||||
s.PkgPath() != "",
|
||||
path,
|
||||
childComment,
|
||||
[]*Action{},
|
||||
Name: s.String(),
|
||||
Hidden: s.PkgPath() != "",
|
||||
Path: path,
|
||||
Comment: childComment,
|
||||
Children: []*Action{},
|
||||
}
|
||||
prevAction.AddChild(a)
|
||||
}
|
||||
|
@@ -38,6 +38,10 @@ func NewRunner(pctx *plancontext.Context, target cue.Path, s solver.Solver) *Run
|
||||
}
|
||||
|
||||
func (r *Runner) Run(ctx context.Context, src *compiler.Value) error {
|
||||
if !src.LookupPath(r.target).Exists() {
|
||||
return fmt.Errorf("%s not found", r.target.String())
|
||||
}
|
||||
|
||||
if err := r.update(cue.MakePath(), src); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user