Skip to content

Commit

Permalink
feat: support OpenTofu (#956)
Browse files Browse the repository at this point in the history
* feat: support OpenTofu

* fix: suppress a lint error
  • Loading branch information
suzuki-shunsuke authored Oct 8, 2023
1 parent 277eeac commit ebd3c72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/terraform/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit ebd3c72

Please sign in to comment.