Skip to content

Commit

Permalink
Fix: env0_template opentofu_version pattern match failure for RESOLVE… (
Browse files Browse the repository at this point in the history
#815)

* Fix: env0_template opentofu_version pattern match failure for RESOLVE_FROM_CODE

* Update env0/resource_template.go

Co-authored-by: Chaim Platonov <[email protected]>

* update regex

---------

Co-authored-by: Chaim Platonov <[email protected]>
  • Loading branch information
TomerHeber and chpl committed Mar 31, 2024
1 parent 4148d76 commit 3fe0808
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion env0/resource_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema {
},
"opentofu_version": {
Type: schema.TypeString,
Description: "the Opentofu version to use (example: 0.36.5)",
Description: "the Opentofu version to use (example: 1.6.2). Setting to 'RESOLVE_FROM_CODE' extracts the version from the Opentofu code during runtime. Setting to `latest`, the version used will be the most recent one available for Opentofu.",
ValidateDiagFunc: NewOpenTofuVersionValidator(),
Optional: true,
},
Expand Down
2 changes: 1 addition & 1 deletion env0/resource_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func TestUnitTemplateResource(t *testing.T) {
Description: "new-description",
Repository: "env0/repo-new",
Type: "opentofu",
OpentofuVersion: "1.7.0",
OpentofuVersion: "RESOLVE_FROM_CODE",
TerraformVersion: "0.15.1",
Retry: client.TemplateRetry{
OnDeploy: &client.TemplateRetryOn{
Expand Down
2 changes: 1 addition & 1 deletion env0/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func NewGreaterThanValidator(greaterThan int) schema.SchemaValidateDiagFunc {
}

func NewOpenTofuVersionValidator() schema.SchemaValidateDiagFunc {
return NewRegexValidator(`^(?:[0-9]\.[0-9]{1,2}\.[0-9]{1,2})|1\.6\.0-alpha$`)
return NewRegexValidator(`(?:^[0-9]\.[0-9]{1,2}\.[0-9]{1,2}(?:-.+)?$)|^RESOLVE_FROM_CODE$|^latest$`)
}

func ValidateTtl(i interface{}, path cty.Path) diag.Diagnostics {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/004_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ resource "env0_template" "template_opentofu" {
retries_on_deploy = 3
retry_on_deploy_only_when_matches_regex = "abc"
retries_on_destroy = 1
opentofu_version = "1.6.0"
opentofu_version = var.second_run ? "1.6.0" : "RESOLVE_FROM_CODE"
}

resource "env0_configuration_variable" "in_a_template" {
Expand Down

0 comments on commit 3fe0808

Please sign in to comment.