Fix waiting group in client runner
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
bfdb2e3655
commit
39ec4a0a2f
@ -104,8 +104,14 @@ func (c *Client) Do(ctx context.Context, state *state.State, fn DoFunc) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
|
||||||
// Close output channel
|
// Close output channel
|
||||||
defer close(ch)
|
defer func() {
|
||||||
|
// Wait until all the events are caught
|
||||||
|
wg.Wait()
|
||||||
|
close(ch)
|
||||||
|
}()
|
||||||
|
|
||||||
lg := log.Ctx(ctx)
|
lg := log.Ctx(ctx)
|
||||||
|
|
||||||
@ -143,7 +149,6 @@ func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.
|
|||||||
Interface("attrs", opts.FrontendAttrs).
|
Interface("attrs", opts.FrontendAttrs).
|
||||||
Msg("spawning buildkit job")
|
Msg("spawning buildkit job")
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
// Catch output from events
|
// Catch output from events
|
||||||
catchOutput := func(inCh chan *bk.SolveStatus) {
|
catchOutput := func(inCh chan *bk.SolveStatus) {
|
||||||
for e := range inCh {
|
for e := range inCh {
|
||||||
@ -220,8 +225,6 @@ func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.
|
|||||||
Msg("exporter response")
|
Msg("exporter response")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until all the events are caught
|
|
||||||
wg.Wait()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user