From d506fb3289de593f76aee803ffa49675c429df4d Mon Sep 17 00:00:00 2001 From: Paul O'Connor <465717+pauloconnor@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:18:04 +0100 Subject: [PATCH] Only highlight Terraform changes on GitHub --- server/events/markdown_renderer_test.go | 58 +++++++++++++++++++++++++ server/events/models/models.go | 6 ++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go index 9a5caf8399..a3019a45b3 100644 --- a/server/events/markdown_renderer_test.go +++ b/server/events/markdown_renderer_test.go @@ -2173,6 +2173,7 @@ Terraform will perform the following actions: id = "redacted_redacted.redacted.redacted.io_A" name = "redacted.redacted.redacted.io" ~ records = [ + "foo", - "redacted", ] -> (known after apply) ttl = 300 @@ -2180,6 +2181,34 @@ Terraform will perform the following actions: zone_id = "redacted" } +# helm_release.external_dns[0] will be updated in-place +~ resource "helm_release" "external_dns" { + id = "external-dns" + name = "external-dns" + ~ values = [ + - <<-EOT + image: + tag: "0.12.0" + pullSecrets: + - XXXXX + + domainFilters: ["xxxxx","xxxxx"] + base64: + +dGhpcyBpcyBzb21lIHN0cmluZyBvciBzb21ldGhpbmcKCg== + EOT, + + <<-EOT + image: + tag: "0.12.0" + pullSecrets: + - XXXXX + + domainFilters: ["xxxxx","xxxxx"] + base64: + +dGhpcyBpcyBzb21lIHN0cmluZyBvciBzb21ldGhpbmcKCg== + EOT, + ] + } + Plan: 1 to add, 1 to change, 1 to destroy. ` cases := []struct { @@ -2308,6 +2337,7 @@ Terraform will perform the following actions: id = "redacted_redacted.redacted.redacted.io_A" name = "redacted.redacted.redacted.io" ! records = [ + "foo", - "redacted", ] -> (known after apply) ttl = 300 @@ -2315,6 +2345,34 @@ Terraform will perform the following actions: zone_id = "redacted" } +# helm_release.external_dns[0] will be updated in-place +! resource "helm_release" "external_dns" { + id = "external-dns" + name = "external-dns" +! values = [ +- <<-EOT + image: + tag: "0.12.0" + pullSecrets: + - XXXXX + + domainFilters: ["xxxxx","xxxxx"] + base64: + +dGhpcyBpcyBzb21lIHN0cmluZyBvciBzb21ldGhpbmcKCg== + EOT, ++ <<-EOT + image: + tag: "0.12.0" + pullSecrets: + - XXXXX + + domainFilters: ["xxxxx","xxxxx"] + base64: + +dGhpcyBpcyBzb21lIHN0cmluZyBvciBzb21ldGhpbmcKCg== + EOT, + ] + } + Plan: 1 to add, 1 to change, 1 to destroy. $$$ diff --git a/server/events/models/models.go b/server/events/models/models.go index 135a2dad93..719efbb4f7 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -363,10 +363,12 @@ func (p *PlanSuccess) Summary() string { // DiffMarkdownFormattedTerraformOutput formats the Terraform output to match diff markdown format func (p PlanSuccess) DiffMarkdownFormattedTerraformOutput() string { - diffKeywordRegex := regexp.MustCompile(`(?m)^( +)([-+~])`) + diffKeywordRegex := regexp.MustCompile(`(?m)^( +)([-+~]\s)(.*)(\s->\s|<<|\{|\(known after apply\)|\[)(.*)`) + diffListRegex := regexp.MustCompile(`(?m)^( +)([-+~]\s)(".*",)`) diffTildeRegex := regexp.MustCompile(`(?m)^~`) - formattedTerraformOutput := diffKeywordRegex.ReplaceAllString(p.TerraformOutput, "$2$1") + formattedTerraformOutput := diffKeywordRegex.ReplaceAllString(p.TerraformOutput, "$2$1$3$4$5") + formattedTerraformOutput = diffListRegex.ReplaceAllString(formattedTerraformOutput, "$2$1$3") formattedTerraformOutput = diffTildeRegex.ReplaceAllString(formattedTerraformOutput, "!") return formattedTerraformOutput