buildr/internal/execution/plan.go
Peter 34c431790e
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
refactor: use connect-go instead of regular Google gRPC
- support binary name for plugins
- register plugins for container jobs
2023-09-12 18:43:34 +02:00

38 lines
703 B
Go

package execution
import (
"context"
"fmt"
"code.icb4dc0.de/buildr/buildr/modules"
)
func NewPlanFor(
moduleType modules.Category,
moduleName string,
repo *modules.Repository,
factory *TaskFactory,
) (*Plan, error) {
target := repo.Module(moduleType, moduleName)
if target == nil {
return nil, fmt.Errorf("%w: %s/%s", modules.ErrNoSuchModule, modules.CategoryName(moduleType), moduleName)
}
entryPoint, err := factory.TaskForModule(target.ID(), repo)
if err != nil {
return nil, err
}
return &Plan{
entryPoint: entryPoint,
}, nil
}
type Plan struct {
entryPoint Task
}
func (p *Plan) Execute(ctx context.Context, spec Spec) error {
return p.entryPoint.Execute(ctx, spec)
}