38 lines
703 B
Go
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)
|
|
}
|