Skip to content

Commit

Permalink
chore: Cherry pick #4474 into release-0.27 (#4475)
Browse files Browse the repository at this point in the history
Co-authored-by: Stas Ostrovskyi <stas.ostrovskyy@gmail.com>
  • Loading branch information
lukemassa and stasostrovskyi committed Apr 25, 2024
1 parent 3155f3d commit c2c26a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/core/terraform/terraform_client.go
Expand Up @@ -338,6 +338,11 @@ func (c *DefaultClient) DetectVersion(log logging.SimpleLogging, projectDirector
}

constraint, _ := version.NewConstraint(requiredVersionSetting)
// Since terraform version 1.8.2, terraform is not a single file download anymore and
// Atlantis fails to download version 1.8.2 and higher. So, as a short-term fix,
// we need to block any version higher than 1.8.1 until proper solution is implemented.
// More details on the issue here - https://github.com/runatlantis/atlantis/issues/4471
highestSupportedConstraint, _ := version.NewConstraint("<= 1.8.1")
versions := make([]*version.Version, len(tfVersions))

for i, tfvals := range tfVersions {
Expand All @@ -355,7 +360,7 @@ func (c *DefaultClient) DetectVersion(log logging.SimpleLogging, projectDirector
sort.Sort(sort.Reverse(version.Collection(versions)))

for _, element := range versions {
if constraint.Check(element) { // Validate a version against a constraint
if constraint.Check(element) && highestSupportedConstraint.Check(element) { // Validate a version against a constraint
tfversionStr := element.String()
if lib.ValidVersionFormat(tfversionStr) { //check if version format is correct
tfversion, _ := version.NewVersion(tfversionStr)
Expand Down
6 changes: 6 additions & 0 deletions server/core/terraform/terraform_client_test.go
Expand Up @@ -393,6 +393,12 @@ terraform {
// cannot use ~> 1.3 or ~> 1.0 since that is a moving target since it will always
// resolve to the latest terraform 1.x
"~> 1.3.0": "1.3.10",
// Since terraform version 1.8.2, terraform is not a single file download anymore and
// Atlantis fails to download version 1.8.2 and higher. So, as a short-term fix,
// we need to block any version higher than 1.8.1 until proper solution is implemented.
// More details on the issue here - https://github.com/runatlantis/atlantis/issues/4471
">= 1.3.0": "1.8.1",
">= 1.8.2": "",
}

type testCase struct {
Expand Down

0 comments on commit c2c26a2

Please sign in to comment.