From c212ba4a768844ead71a942b9408804b3e576c47 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Sun, 11 Aug 2024 07:38:22 -0500 Subject: [PATCH] added 'latest' as a possible version --- client/template.go | 2 +- env0/resource_template.go | 2 +- env0/resource_template_test.go | 2 +- tests/integration/004_template/main.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/template.go b/client/template.go index e34e816d..b121592a 100644 --- a/client/template.go +++ b/client/template.go @@ -158,7 +158,7 @@ func (payload *TemplateCreatePayload) Invalidate() error { } } - if payload.Type == "ansible" { + if payload.Type == "ansible" && payload.AnsibleVersion != "latest" { if payload.AnsibleVersion == "" { return errors.New("'ansible_version' is required") } diff --git a/env0/resource_template.go b/env0/resource_template.go index 86e4a5d8..dcf21838 100644 --- a/env0/resource_template.go +++ b/env0/resource_template.go @@ -260,7 +260,7 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema { Type: schema.TypeString, Description: "the ansible version to use (required when the template type is 'ansible'). Supported versions are 3.0.0 and above", Optional: true, - ValidateDiagFunc: NewRegexValidator(`^(?:[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2})|$`), + ValidateDiagFunc: NewRegexValidator(`^(?:[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2})|latest|$`), Default: "", }, } diff --git a/env0/resource_template_test.go b/env0/resource_template_test.go index d1c5c731..f8908247 100644 --- a/env0/resource_template_test.go +++ b/env0/resource_template_test.go @@ -475,7 +475,7 @@ func TestUnitTemplateResource(t *testing.T) { Description: "new-description", Repository: "env0/repo-new", Type: "ansible", - AnsibleVersion: "11.5.6", + AnsibleVersion: "latest", Retry: client.TemplateRetry{ OnDeploy: &client.TemplateRetryOn{ Times: 2, diff --git a/tests/integration/004_template/main.tf b/tests/integration/004_template/main.tf index 02d0d892..e12de624 100644 --- a/tests/integration/004_template/main.tf +++ b/tests/integration/004_template/main.tf @@ -77,7 +77,7 @@ resource "env0_template" "template_ansible" { retries_on_deploy = 3 retry_on_deploy_only_when_matches_regex = "abc" retries_on_destroy = 1 - ansible_version = var.second_run ? "3.6.0" : "9.5.0" + ansible_version = var.second_run ? "3.6.0" : "latest" } resource "env0_configuration_variable" "in_a_template" {