minamijoyo / tfupdate

Update version constraints in your Terraform configurations
MIT License
539 stars 23 forks source link

Fix a regression issue for updating .hcl file #97

Closed minamijoyo closed 1 year ago

minamijoyo commented 1 year ago

Fixes #96

When the filename is intentionally specified, we should not ignore it by its extension as much as possible.

$ cat tmp/test.hcl
terraform {
  required_version = "1.5.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.3.0"
    }
  }
}

$ go run main.go terraform -v 1.5.2 tmp/test.hcl

$ cat tmp/test.hcl
terraform {
  required_version = "1.5.2"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.3.0"
    }
  }
}

$ go run main.go provider aws -v 5.7.0 tmp/test.hcl

$ cat tmp/test.hcl
terraform {
  required_version = "1.5.2"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.7.0"
    }
  }
}