Skip to content

Commit

Permalink
So for whatever reason tf show with big plan doesn't work in async
Browse files Browse the repository at this point in the history
  • Loading branch information
msarvar committed Sep 28, 2021
1 parent b5018de commit b04388e
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions server/events/terraform/terraform_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}()
Expand Down

0 comments on commit b04388e

Please sign in to comment.