Skip to content

Commit

Permalink
runatlantis#1306 Filter out fetching resources output from terraform …
Browse files Browse the repository at this point in the history
…commands
  • Loading branch information
levkk committed Dec 20, 2020
1 parent d09e798 commit 8450fa1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server/events/terraform/terraform_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,23 @@ func (c *DefaultClient) RunCommandWithVersion(log *logging.SimpleLogger, path st
}
cmd.Env = envVars
out, err := cmd.CombinedOutput()

if err != nil {
err = errors.Wrapf(err, "running %q in %q", tfCmd, path)
log.Err(err.Error())
return string(out), err
}

// Filter out terraform fetching resources if no errors happened
lines := strings.Split(string(out), "\n")
filtered := make([]string, len(lines))
for _, s := range lines {
if !strings.Contains(s, "Refreshing state...") {
filtered = append(filtered, s + "\n");
}
}
log.Info("successfully ran %q in %q", tfCmd, path)
return string(out), nil
return strings.Join(filtered, "\n"), nil
}

// prepCmd builds a ready to execute command based on the version of terraform
Expand Down

0 comments on commit 8450fa1

Please sign in to comment.