Skip to content

Commit

Permalink
Feat: env0_environment_discovery_configuration resource is missing pa…
Browse files Browse the repository at this point in the history
…ram for root_path
  • Loading branch information
TomerHeber committed Jul 19, 2024
1 parent 1bc1849 commit 7200aa7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/environment_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions env0/resource_environment_discovery_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
}
Expand Down
8 changes: 8 additions & 0 deletions env0/resource_environment_discovery_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) {
WorkspaceNaming: "default",
OpentofuVersion: "1.6.2",
GithubInstallationId: 12345,
RootPath: "/path",
}

getPayload := client.EnvironmentDiscoveryPayload{
Expand All @@ -40,6 +41,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) {
WorkspaceNaming: putPayload.WorkspaceNaming,
OpentofuVersion: putPayload.OpentofuVersion,
GithubInstallationId: putPayload.GithubInstallationId,
RootPath: putPayload.RootPath,
}

updatePutPayload := client.EnvironmentDiscoveryPutPayload{
Expand All @@ -52,6 +54,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) {
TerragruntVersion: "0.63.0",
GithubInstallationId: 3213,
TerragruntTfBinary: "opentofu",
RootPath: "/path2",
}

updateGetPayload := client.EnvironmentDiscoveryPayload{
Expand All @@ -65,6 +68,7 @@ func TestUnitEnvironmentDiscoveryConfigurationResource(t *testing.T) {
TerragruntVersion: updatePutPayload.TerragruntVersion,
GithubInstallationId: updatePutPayload.GithubInstallationId,
TerragruntTfBinary: "opentofu",
RootPath: updatePutPayload.RootPath,
}

testCase := resource.TestCase{
Expand All @@ -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),
Expand All @@ -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),
),
},
{
Expand All @@ -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),
Expand All @@ -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),
),
},
},
Expand Down

0 comments on commit 7200aa7

Please sign in to comment.