From a45150dd0f0abbcf902196235ba043a19470dce0 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Fri, 19 Jul 2024 08:44:52 -0500 Subject: [PATCH 1/2] Feat: env0_environment_discovery_configuration resource is missing param for root_path (#899) --- client/environment_discovery.go | 2 ++ env0/resource_environment_discovery_configuration.go | 5 +++++ env0/resource_environment_discovery_configuration_test.go | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/client/environment_discovery.go b/client/environment_discovery.go index 6f823af6..65f8df16 100644 --- a/client/environment_discovery.go +++ b/client/environment_discovery.go @@ -19,6 +19,7 @@ type EnvironmentDiscoveryPutPayload struct { BitbucketClientKey string `json:"bitbucketClientKey,omitempty"` IsAzureDevops bool `json:"isAzureDevOps"` Retry TemplateRetry `json:"retry"` + RootPath string `json:"rootPath"` } type EnvironmentDiscoveryPayload struct { @@ -41,6 +42,7 @@ type EnvironmentDiscoveryPayload struct { BitbucketClientKey string `json:"bitbucketClientKey"` IsAzureDevops bool `json:"isAzureDevOps"` Retry TemplateRetry `json:"retry" tfschema:"-"` + RootPath string `json:"rootPath"` } func (client *ApiClient) PutEnvironmentDiscovery(projectId string, payload *EnvironmentDiscoveryPutPayload) (*EnvironmentDiscoveryPayload, error) { diff --git a/env0/resource_environment_discovery_configuration.go b/env0/resource_environment_discovery_configuration.go index 150368b6..0ea91e49 100644 --- a/env0/resource_environment_discovery_configuration.go +++ b/env0/resource_environment_discovery_configuration.go @@ -160,6 +160,11 @@ func resourceEnvironmentDiscoveryConfiguration() *schema.Resource { Description: "a token id to be used with 'gitlab' or 'azure_devops'", Optional: true, }, + "root_path": { + Type: schema.TypeString, + Description: "start files Glob matching from this folder only", + Optional: true, + }, }, } } diff --git a/env0/resource_environment_discovery_configuration_test.go b/env0/resource_environment_discovery_configuration_test.go index f805dfd1..b5f9e087 100644 --- a/env0/resource_environment_discovery_configuration_test.go +++ b/env0/resource_environment_discovery_configuration_test.go @@ -29,6 +29,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { WorkspaceNaming: "default", OpentofuVersion: "1.6.2", GithubInstallationId: 12345, + RootPath: "/path", } getPayload := client.EnvironmentDiscoveryPayload{ @@ -40,6 +41,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { WorkspaceNaming: putPayload.WorkspaceNaming, OpentofuVersion: putPayload.OpentofuVersion, GithubInstallationId: putPayload.GithubInstallationId, + RootPath: putPayload.RootPath, } updatePutPayload := client.EnvironmentDiscoveryPutPayload{ @@ -52,6 +54,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { TerragruntVersion: "0.63.0", GithubInstallationId: 3213, TerragruntTfBinary: "opentofu", + RootPath: "/path2", } updateGetPayload := client.EnvironmentDiscoveryPayload{ @@ -65,6 +68,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { TerragruntVersion: updatePutPayload.TerragruntVersion, GithubInstallationId: updatePutPayload.GithubInstallationId, TerragruntTfBinary: "opentofu", + RootPath: updatePutPayload.RootPath, } testCase := resource.TestCase{ @@ -76,6 +80,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { "repository": putPayload.Repository, "opentofu_version": putPayload.OpentofuVersion, "github_installation_id": putPayload.GithubInstallationId, + "root_path": putPayload.RootPath, }), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(accessor, "project_id", projectId), @@ -86,6 +91,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { resource.TestCheckResourceAttr(accessor, "workspace_naming", putPayload.WorkspaceNaming), resource.TestCheckResourceAttr(accessor, "opentofu_version", putPayload.OpentofuVersion), resource.TestCheckResourceAttr(accessor, "github_installation_id", strconv.Itoa(putPayload.GithubInstallationId)), + resource.TestCheckResourceAttr(accessor, "root_path", putPayload.RootPath), ), }, { @@ -97,6 +103,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { "github_installation_id": updatePutPayload.GithubInstallationId, "type": updatePutPayload.Type, "terragrunt_version": updatePutPayload.TerragruntVersion, + "root_path": updatePutPayload.RootPath, }), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(accessor, "project_id", projectId), @@ -108,6 +115,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) { resource.TestCheckResourceAttr(accessor, "opentofu_version", updatePutPayload.OpentofuVersion), resource.TestCheckResourceAttr(accessor, "github_installation_id", strconv.Itoa(updatePutPayload.GithubInstallationId)), resource.TestCheckResourceAttr(accessor, "terragrunt_version", updatePutPayload.TerragruntVersion), + resource.TestCheckResourceAttr(accessor, "root_path", updatePutPayload.RootPath), ), }, }, From 588f12b2fc254f42e6794487e6b6276f0d46d83e Mon Sep 17 00:00:00 2001 From: update generated docs action Date: Fri, 19 Jul 2024 13:45:28 +0000 Subject: [PATCH 2/2] Update docs --- docs/resources/environment_discovery_configuration.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/resources/environment_discovery_configuration.md b/docs/resources/environment_discovery_configuration.md index 3c6b9448..96d3b8c1 100644 --- a/docs/resources/environment_discovery_configuration.md +++ b/docs/resources/environment_discovery_configuration.md @@ -64,6 +64,7 @@ resource "env0_environment_discovery_configuration" "terragrunt_example" { - `retries_on_destroy` (Number) number of times to retry when destroy fails (between 1 and 3) - `retry_on_deploy_only_when_matches_regex` (String) retry (on deploy) if error matches the specified regex - `retry_on_destroy_only_when_matches_regex` (String) retry (on destroy) if error matches the specified regex +- `root_path` (String) start files Glob matching from this folder only - `ssh_key_id` (String) The ssh key id that will be available during deployment - `ssh_key_name` (String) The ssh key name that will be available during deployment - `terraform_version` (String) the Terraform version to use (example: 1.7.4). Setting to `RESOLVE_FROM_TERRAFORM_CODE` defaults to the version of `terraform.required_version` during run-time (resolve from terraform code). Setting to `latest`, the version used will be the most recent one available for Terraform.