From b04388e6caab15b49583449e006b74f09f2b15f9 Mon Sep 17 00:00:00 2001 From: Sarvar Muminov Date: Mon, 27 Sep 2021 18:13:36 -0700 Subject: [PATCH] So for whatever reason tf show with big plan doesn't work in async --- server/events/terraform/terraform_client.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/server/events/terraform/terraform_client.go b/server/events/terraform/terraform_client.go index 8ee295ee9..248fba419 100644 --- a/server/events/terraform/terraform_client.go +++ b/server/events/terraform/terraform_client.go @@ -291,7 +291,8 @@ func (c *DefaultClient) RunCommandWithVersion(ctx models.ProjectCommandContext, } // if the feature is enabled, we use the async workflow else we default to the original sync workflow - if shouldAllocate { + // Don't stream terraform show output to outCh + if shouldAllocate && isValidCommand(args[0]) { _, outCh := c.RunCommandAsync(ctx, path, args, customEnvVars, v, workspace) var lines []string var err error @@ -442,30 +443,21 @@ func (c *DefaultClient) RunCommandAsync(ctx models.ProjectCommandContext, path s // Asynchronously copy from stdout/err to outCh. go func() { - // Don't stream terraform show output to outCh - cmds := strings.Split(tfCmd, " ") - if isValidCommand(cmds[1]) { - c.projectCmdOutputHandler.Send(ctx, fmt.Sprintf("\n----- running terraform %s -----", args[0])) - } + c.projectCmdOutputHandler.Send(ctx, fmt.Sprintf("\n----- running terraform %s -----", args[0])) s := bufio.NewScanner(stdout) for s.Scan() { message := s.Text() outCh <- Line{Line: message} - if isValidCommand(cmds[1]) { - c.projectCmdOutputHandler.Send(ctx, "\t"+message) - } + c.projectCmdOutputHandler.Send(ctx, "\t"+message) } wg.Done() }() go func() { - cmds := strings.Split(tfCmd, " ") s := bufio.NewScanner(stderr) for s.Scan() { message := s.Text() outCh <- Line{Line: message} - if isValidCommand(cmds[1]) { - c.projectCmdOutputHandler.Send(ctx, message) - } + c.projectCmdOutputHandler.Send(ctx, message) } wg.Done() }()