bake: use controller to build

With this change we are now passing a list of controller options
to run a build and returns a map of responses and result context
as bake can handle a list of targets.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-06-01 17:42:34 +02:00
committed by CrazyMax
parent 9387640676
commit 9df197046c
8 changed files with 265 additions and 203 deletions

View File

@@ -668,7 +668,7 @@ func Build(ctx context.Context, nodes []builder.Node, opt map[string]Options, do
return BuildWithResultHandler(ctx, nodes, opt, docker, configDir, w, nil)
}
func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[string]Options, docker *dockerutil.Client, configDir string, w progress.Writer, resultHandleFunc func(driverIndex int, rCtx *ResultHandle)) (resp map[string]*client.SolveResponse, err error) {
func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[string]Options, docker *dockerutil.Client, configDir string, w progress.Writer, resultHandleFunc func(target string, rCtx *ResultHandle)) (resp map[string]*client.SolveResponse, err error) {
if len(nodes) == 0 {
return nil, errors.Errorf("driver required for build")
}
@@ -938,7 +938,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
if resultHandleFunc != nil {
var resultHandle *ResultHandle
resultHandle, rr, err = NewResultHandle(ctx, cc, so, "buildx", buildFunc, ch)
resultHandleFunc(dp.driverIndex, resultHandle)
resultHandleFunc(k, resultHandle)
} else {
rr, err = c.Build(ctx, so, "buildx", buildFunc, ch)
}