Skip to content

Commit

Permalink
fix tests and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes committed Sep 16, 2024
1 parent 898c124 commit b182294
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 6 additions & 4 deletions libs/execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,17 @@ func (d DiggerExecutor) Apply() (*terraform_utils.TerraformSummary, bool, string
applyArgs = append(applyArgs, step.ExtraArgs...)
stdout, stderr, err := d.TerraformExecutor.Apply(applyArgs, plansFilename, d.CommandEnvVars)
applyOutput = cleanupTerraformApply(true, err, stdout, stderr)
summary, err = terraform_utils.GetSummaryFromTerraformApplyOutput(stdout)
if err != nil {
log.Printf("Warning: get summary from apply output failed: %v", err)
}

reportTerraformApplyOutput(d.Reporter, d.projectId(), applyOutput)
if err != nil {
reportApplyError(d.Reporter, err)
return nil, false, stdout, fmt.Errorf("error executing apply: %v", err)
}

summary, err = terraform_utils.GetSummaryFromTerraformApplyOutput(stdout)
if err != nil {
log.Printf("Warning: get summary from apply output failed: %v", err)
}
}
if step.Action == "run" {
var commands []string
Expand Down
4 changes: 0 additions & 4 deletions libs/terraform_utils/plan_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"log"
"regexp"
"sort"
"strings"
Expand Down Expand Up @@ -114,7 +113,6 @@ func GetSummaryFromTerraformApplyOutput(applyOutput string) (TerraformSummary, e
for scanner.Scan() {
line := scanner.Text()
if matches := summaryRegex.FindStringSubmatch(line); matches != nil {
log.Printf("matches found: %v", matches)
foundResourcesLine = true
fmt.Sscanf(matches[1], "%d", &added)
fmt.Sscanf(matches[2], "%d", &changed)
Expand All @@ -126,8 +124,6 @@ func GetSummaryFromTerraformApplyOutput(applyOutput string) (TerraformSummary, e
return TerraformSummary{}, fmt.Errorf("could not find resources line in terraform apply output")
}

log.Printf("finished scan of terraform output: %v", applyOutput)
log.Printf("values found: %v %v %v", added, changed, destroyed)
return TerraformSummary{
ResourcesCreated: added,
ResourcesUpdated: changed,
Expand Down

0 comments on commit b182294

Please sign in to comment.