Go 37 lines
package workflow
import "sort"
// Registry maps a workflow name to its native implementation. The
// builtins are read-only and ship in the binary; user workflows live in
// the workspace and are run by the script runner, not registered here.
type Registry struct {
builtins map[string]Workflow
}
// DefaultRegistry returns the registry of builtin workflows available in
// this milestone.
func DefaultRegistry() *Registry {
r := &Registry{builtins: map[string]Workflow{}}
for _, w := range []Workflow{commentHygiene{}, leakGuard{}, bugSweep{}, handoverRefresh{}, evolve{}, versionSync{}, buildGate{}, memoryDrift{}, docDrift{}, manifestRefresh{}, cockpitSync{}} {
r.builtins[w.Name()] = w
}
return r
}
// Get returns the named builtin and whether it exists.
func (r *Registry) Get(name string) (Workflow, bool) {
w, ok := r.builtins[name]
return w, ok
}
// Names returns the builtin workflow names, sorted.
func (r *Registry) Names() []string {
names := make([]string, 0, len(r.builtins))
for n := range r.builtins {
names = append(names, n)
}
sort.Strings(names)
return names
}