From ebd3c7221bf26d51d3cdd0838844dcf14d28ba80 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sun, 8 Oct 2023 22:04:50 +0900 Subject: [PATCH] feat: support OpenTofu (#956) * feat: support OpenTofu * fix: suppress a lint error --- pkg/terraform/parser.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/terraform/parser.go b/pkg/terraform/parser.go index 892a62be..72a30aab 100644 --- a/pkg/terraform/parser.go +++ b/pkg/terraform/parser.go @@ -104,7 +104,7 @@ func extractMovedResource(pattern *regexp.Regexp, line string) *MovedResource { } // Parse returns ParseResult related with terraform plan -func (p *PlanParser) Parse(body string) ParseResult { //nolint:cyclop +func (p *PlanParser) Parse(body string) ParseResult { //nolint:cyclop,maintidx switch { case p.Fail.MatchString(body): case p.Pass.MatchString(body) || p.OutputsChanges.MatchString(body): @@ -128,13 +128,13 @@ func (p *PlanParser) Parse(body string) ParseResult { //nolint:cyclop endWarning := -1 startErrorIndex := -1 for i, line := range lines { - if line == "Note: Objects have changed outside of Terraform" { // https://github.com/hashicorp/terraform/blob/332045a4e4b1d256c45f98aac74e31102ace7af7/internal/command/views/plan.go#L403 + if line == "Note: Objects have changed outside of Terraform" || line == "Note: Objects have changed outside of OpenTofu" { // https://github.com/hashicorp/terraform/blob/332045a4e4b1d256c45f98aac74e31102ace7af7/internal/command/views/plan.go#L403 startOutsideTerraform = i + 1 } if startOutsideTerraform != -1 && endOutsideTerraform == -1 && strings.HasPrefix(line, "Unless you have made equivalent changes to your configuration") { // https://github.com/hashicorp/terraform/blob/332045a4e4b1d256c45f98aac74e31102ace7af7/internal/command/views/plan.go#L110 endOutsideTerraform = i + 1 } - if line == "Terraform will perform the following actions:" { // https://github.com/hashicorp/terraform/blob/332045a4e4b1d256c45f98aac74e31102ace7af7/internal/command/views/plan.go#L252 + if line == "Terraform will perform the following actions:" || line == "OpenTofu will perform the following actions:" { // https://github.com/hashicorp/terraform/blob/332045a4e4b1d256c45f98aac74e31102ace7af7/internal/command/views/plan.go#L252 startChangeOutput = i + 1 } // If we have output changes but not resource changes, Terraform