Skip to content

Commit

Permalink
chore: improve plan results message when only Outputs will be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
taro-kayo committed Sep 9, 2023
1 parent 5d98cba commit 6fa879f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion pkg/terraform/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (p *PlanParser) Parse(body string) ParseResult { //nolint:cyclop
}

return ParseResult{
Result: result,
Result: refinePlanResult(result),
ChangedResult: changeResult,
OutsideTerraform: outsideTerraform,
Warning: warnings,
Expand All @@ -245,6 +245,15 @@ func (p *PlanParser) Parse(body string) ParseResult { //nolint:cyclop
}
}

// It can be difficult to understand if we just cut out a part of
// Terraform's output, so rewrite the text in a way that users can understand.
func refinePlanResult(s string) string {
if s == "Changes to Outputs:" {
return "Only Outputs will be changed."
}
return s
}

type MovedResource struct {
Before string
After string
Expand Down
4 changes: 2 additions & 2 deletions pkg/terraform/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ Changes to Outputs:
name: "plan output changes only pattern 0.15",
body: planOnlyOutputChangesSuccessResult0_15,
result: ParseResult{
Result: "Changes to Outputs:",
Result: "Only Outputs will be changed.",
HasAddOrUpdateOnly: true,
HasDestroy: false,
HasNoChanges: false,
Expand All @@ -454,7 +454,7 @@ state, without changing any real infrastructure.`,
name: "plan output changes only pattern with TF_IN_AUTOMATION",
body: planOnlyOutputChangesSuccessInAutomationResult,
result: ParseResult{
Result: "Changes to Outputs:",
Result: "Only Outputs will be changed.",
HasAddOrUpdateOnly: true,
HasDestroy: false,
HasNoChanges: false,
Expand Down

0 comments on commit 6fa879f

Please sign in to comment.