From 3fe0808bf37b398ef95fa6cf2561197e203abccb Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Sun, 31 Mar 2024 11:02:47 -0500 Subject: [PATCH] =?UTF-8?q?Fix:=20env0=5Ftemplate=20opentofu=5Fversion=20p?= =?UTF-8?q?attern=20match=20failure=20for=20RESOLVE=E2=80=A6=20(#815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: env0_template opentofu_version pattern match failure for RESOLVE_FROM_CODE * Update env0/resource_template.go Co-authored-by: Chaim Platonov * update regex --------- Co-authored-by: Chaim Platonov --- env0/resource_template.go | 2 +- env0/resource_template_test.go | 2 +- env0/validators.go | 2 +- tests/integration/004_template/main.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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" {