engine: Task PreRun Hook

Tasks now have a PreRun hook that gets called before buildkit kicks in.
Allows to support local access without special casing.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-12-23 20:23:52 +01:00
parent 06b05746b8
commit 2982a0dda0
4 changed files with 58 additions and 24 deletions

View File

@@ -29,6 +29,12 @@ type Task interface {
Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error)
}
type PreRunner interface {
Task
PreRun(ctx context.Context, pctx *plancontext.Context, v *compiler.Value) error
}
// Register a task type and initializer
func Register(typ string, f NewFunc) {
tasks.Store(typ, f)