diff --git a/pkg/compose/plugins.go b/pkg/compose/plugins.go index fd0b48ff76c..d7903056113 100644 --- a/pkg/compose/plugins.go +++ b/pkg/compose/plugins.go @@ -33,7 +33,6 @@ import ( "github.com/spf13/cobra" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/propagation" - "golang.org/x/sync/errgroup" ) type JsonMessage struct { @@ -75,7 +74,19 @@ func (s *composeService) runPlugin(ctx context.Context, project *types.Project, } func (s *composeService) executePlugin(ctx context.Context, cmd *exec.Cmd, command string, service types.ServiceConfig) (types.Mapping, error) { - eg := errgroup.Group{} + pw := progress.ContextWriter(ctx) + var action string + switch command { + case "up": + pw.Event(progress.CreatingEvent(service.Name)) + action = "create" + case "down": + pw.Event(progress.RemovingEvent(service.Name)) + action = "remove" + default: + return nil, fmt.Errorf("unsupported plugin command: %s", command) + } + stdout, err := cmd.StdoutPipe() if err != nil { return nil, err @@ -85,25 +96,12 @@ func (s *composeService) executePlugin(ctx context.Context, cmd *exec.Cmd, comma if err != nil { return nil, err } - eg.Go(cmd.Wait) decoder := json.NewDecoder(stdout) defer func() { _ = stdout.Close() }() variables := types.Mapping{} - pw := progress.ContextWriter(ctx) - var action string - switch command { - case "up": - pw.Event(progress.CreatingEvent(service.Name)) - action = "create" - case "down": - pw.Event(progress.RemovingEvent(service.Name)) - action = "remove" - default: - return nil, fmt.Errorf("unsupported plugin command: %s", command) - } for { var msg JsonMessage err = decoder.Decode(&msg) @@ -130,10 +128,10 @@ func (s *composeService) executePlugin(ctx context.Context, cmd *exec.Cmd, comma } } - err = eg.Wait() + err = cmd.Wait() if err != nil { pw.Event(progress.ErrorMessageEvent(service.Name, err.Error())) - return nil, fmt.Errorf("failed to %s external service: %s", action, err.Error()) + return nil, fmt.Errorf("failed to %s service provider: %s", action, err.Error()) } switch command { case "up":