buildkit client does not return environment to force the caller to implement its logic in the build callback

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-07-13 16:15:34 +02:00
parent ce7adc1fa4
commit ac32d6f57b

View File

@ -69,13 +69,13 @@ func New(ctx context.Context, host string, noCache bool) (*Client, error) {
type DoFunc func(context.Context, *environment.Environment, solver.Solver) error type DoFunc func(context.Context, *environment.Environment, solver.Solver) error
// FIXME: return completed *Route, instead of *compiler.Value // FIXME: return completed *Route, instead of *compiler.Value
func (c *Client) Do(ctx context.Context, state *state.State, fn DoFunc) (*environment.Environment, error) { func (c *Client) Do(ctx context.Context, state *state.State, fn DoFunc) error {
lg := log.Ctx(ctx) lg := log.Ctx(ctx)
eg, gctx := errgroup.WithContext(ctx) eg, gctx := errgroup.WithContext(ctx)
environment, err := environment.New(state) environment, err := environment.New(state)
if err != nil { if err != nil {
return nil, err return err
} }
// Spawn print function // Spawn print function
@ -92,7 +92,7 @@ func (c *Client) Do(ctx context.Context, state *state.State, fn DoFunc) (*enviro
return c.buildfn(gctx, state, environment, fn, events) return c.buildfn(gctx, state, environment, fn, events)
}) })
return environment, eg.Wait() return eg.Wait()
} }
func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.Environment, fn DoFunc, ch chan *bk.SolveStatus) error { func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.Environment, fn DoFunc, ch chan *bk.SolveStatus) error {