This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/plan/action.go
Richard Jones 6cdf13223c
implements dagger do
Signed-off-by: Richard Jones <richard@dagger.io>
2022-03-01 13:01:26 -07:00

35 lines
562 B
Go

package plan
import (
"cuelang.org/go/cue"
)
type Action struct {
Name string
Hidden bool
Path cue.Path
Comment string
Children []*Action
// pkg string
}
func (a *Action) AddChild(c *Action) {
a.Children = append(a.Children, c)
}
func (a *Action) FindByPath(path cue.Path) *Action {
queue := []*Action{a}
for len(queue) > 0 {
nextUp := queue[0]
queue = queue[1:]
if nextUp.Path.String() == path.String() {
return nextUp
}
if len(nextUp.Children) > 0 {
queue = append(queue, nextUp.Children...)
}
}
return nil
}