diff --git a/env0/resource_template.go b/env0/resource_template.go index e249fa5d..6b21048a 100644 --- a/env0/resource_template.go +++ b/env0/resource_template.go @@ -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, }, diff --git a/env0/resource_template_test.go b/env0/resource_template_test.go index 2e51abad..57fb4d25 100644 --- a/env0/resource_template_test.go +++ b/env0/resource_template_test.go @@ -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{ diff --git a/env0/validators.go b/env0/validators.go index e27ab360..35dab28b 100644 --- a/env0/validators.go +++ b/env0/validators.go @@ -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 { diff --git a/tests/integration/004_template/main.tf b/tests/integration/004_template/main.tf index 6a0fb76c..39711c86 100644 --- a/tests/integration/004_template/main.tf +++ b/tests/integration/004_template/main.tf @@ -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" {