From 28d2399c4394bff239bdb5f8f11377141dd7297b Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Tue, 7 May 2024 07:32:34 -0500 Subject: [PATCH] Feat: is_azure_devops property is not included in data.template and module resource (#846) --- client/module.go | 3 +++ env0/data_module.go | 10 ++++++++++ env0/data_module_test.go | 2 ++ env0/data_template.go | 6 ++++++ env0/data_template_test.go | 2 ++ env0/resource_module.go | 6 ++++++ env0/resource_module_test.go | 5 +++++ 7 files changed, 34 insertions(+) diff --git a/client/module.go b/client/module.go index 3c03d060..301fbc65 100644 --- a/client/module.go +++ b/client/module.go @@ -30,6 +30,7 @@ type Module struct { ModuleTestEnabled bool `json:"moduleTestEnabled"` RunTestsOnPullRequest bool `json:"runTestsOnPullRequest"` OpentofuVersion string `json:"opentofuVersion"` + IsAzureDevOps bool `json:"isAzureDevOps" tfschema:"is_azure_devops"` } type ModuleCreatePayload struct { @@ -49,6 +50,7 @@ type ModuleCreatePayload struct { ModuleTestEnabled bool `json:"moduleTestEnabled"` RunTestsOnPullRequest bool `json:"runTestsOnPullRequest"` OpentofuVersion string `json:"opentofuVersion,omitempty"` + IsAzureDevOps bool `json:"isAzureDevOps" tfschema:"is_azure_devops"` } type ModuleCreatePayloadWith struct { @@ -74,6 +76,7 @@ type ModuleUpdatePayload struct { ModuleTestEnabled bool `json:"moduleTestEnabled"` RunTestsOnPullRequest bool `json:"runTestsOnPullRequest"` OpentofuVersion string `json:"opentofuVersion,omitempty"` + IsAzureDevOps bool `json:"isAzureDevOps" tfschema:"is_azure_devops"` } func (client *ApiClient) ModuleCreate(payload ModuleCreatePayload) (*Module, error) { diff --git a/env0/data_module.go b/env0/data_module.go index 138ef674..b4c2f374 100644 --- a/env0/data_module.go +++ b/env0/data_module.go @@ -39,21 +39,31 @@ func dataModule() *schema.Resource { Type: schema.TypeString, Description: "the token id used for integration with GitLab", Optional: true, + Computed: true, }, "token_name": { Type: schema.TypeString, Description: "the token name used for integration with GitLab", Optional: true, + Computed: true, }, "github_installation_id": { Type: schema.TypeInt, Description: "the env0 application installation id on the relevant github repository", Optional: true, + Computed: true, }, "bitbucket_client_key": { Type: schema.TypeString, Description: "the client key used for integration with Bitbucket", Optional: true, + Computed: true, + }, + "is_azure_devops": { + Type: schema.TypeBool, + Description: "true if this module integrates with azure dev ops", + Optional: true, + Computed: true, }, }, } diff --git a/env0/data_module_test.go b/env0/data_module_test.go index ccdee334..c68f0a47 100644 --- a/env0/data_module_test.go +++ b/env0/data_module_test.go @@ -18,6 +18,7 @@ func TestModuleDataSource(t *testing.T) { TokenId: "t0", TokenName: "n0", Repository: "r0", + IsAzureDevOps: true, } otherModule := client.Module{ @@ -48,6 +49,7 @@ func TestModuleDataSource(t *testing.T) { resource.TestCheckResourceAttr(accessor, "token_id", module.TokenId), resource.TestCheckResourceAttr(accessor, "token_name", module.TokenName), resource.TestCheckResourceAttr(accessor, "repository", module.Repository), + resource.TestCheckResourceAttr(accessor, "is_azure_devops", "true"), ), }, }, diff --git a/env0/data_template.go b/env0/data_template.go index 08b61a84..db1a2933 100644 --- a/env0/data_template.go +++ b/env0/data_template.go @@ -126,6 +126,12 @@ func dataTemplate() *schema.Resource { Optional: true, Computed: true, }, + "is_azure_devops": { + Type: schema.TypeBool, + Description: "true if this template integrates with azure dev ops", + Optional: true, + Computed: true, + }, "ssh_keys": { Type: schema.TypeList, Description: "an array of references to 'data_ssh_key' to use when accessing git over ssh", diff --git a/env0/data_template_test.go b/env0/data_template_test.go index 5e0a4bed..d931b7d6 100644 --- a/env0/data_template_test.go +++ b/env0/data_template_test.go @@ -41,6 +41,7 @@ func TestUnitTemplateData(t *testing.T) { {Id: "id", Name: "name"}, }, IsBitbucketServer: true, + IsAzureDevOps: true, } getValidTestCase := func(input map[string]interface{}) resource.TestCase { @@ -67,6 +68,7 @@ func TestUnitTemplateData(t *testing.T) { resource.TestCheckResourceAttr(resourceFullName, "ssh_keys.0.id", template.SshKeys[0].Id), resource.TestCheckResourceAttr(resourceFullName, "ssh_keys.0.name", template.SshKeys[0].Name), resource.TestCheckResourceAttr(resourceFullName, "is_bitbucket_server", "true"), + resource.TestCheckResourceAttr(resourceFullName, "is_azure_devops", "true"), ), }, }, diff --git a/env0/resource_module.go b/env0/resource_module.go index fc46099b..097c52a8 100644 --- a/env0/resource_module.go +++ b/env0/resource_module.go @@ -113,6 +113,12 @@ func resourceModule() *schema.Resource { RequiredWith: []string{"module_test_enabled"}, ValidateDiagFunc: NewOpenTofuVersionValidator(), }, + "is_azure_devops": { + Type: schema.TypeBool, + Description: "true if this module integrates with azure dev ops", + Optional: true, + Default: false, + }, }, } } diff --git a/env0/resource_module_test.go b/env0/resource_module_test.go index 3d63c6fc..dfb479d2 100644 --- a/env0/resource_module_test.go +++ b/env0/resource_module_test.go @@ -55,6 +55,7 @@ func TestUnitModuleResource(t *testing.T) { ModuleTestEnabled: true, OpentofuVersion: "1.8.0", RunTestsOnPullRequest: false, + IsAzureDevOps: true, } t.Run("Success", func(t *testing.T) { @@ -87,6 +88,7 @@ func TestUnitModuleResource(t *testing.T) { resource.TestCheckResourceAttr(accessor, "module_test_enabled", "true"), resource.TestCheckResourceAttr(accessor, "run_tests_on_pull_request", "true"), resource.TestCheckResourceAttr(accessor, "opentofu_version", module.OpentofuVersion), + resource.TestCheckResourceAttr(accessor, "is_azure_devops", "false"), ), }, { @@ -100,6 +102,7 @@ func TestUnitModuleResource(t *testing.T) { "tag_prefix": updatedModule.TagPrefix, "module_test_enabled": updatedModule.ModuleTestEnabled, "opentofu_version": updatedModule.OpentofuVersion, + "is_azure_devops": updatedModule.IsAzureDevOps, }), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(accessor, "id", updatedModule.Id), @@ -115,6 +118,7 @@ func TestUnitModuleResource(t *testing.T) { resource.TestCheckResourceAttr(accessor, "module_test_enabled", "true"), resource.TestCheckResourceAttr(accessor, "run_tests_on_pull_request", "false"), resource.TestCheckResourceAttr(accessor, "opentofu_version", updatedModule.OpentofuVersion), + resource.TestCheckResourceAttr(accessor, "is_azure_devops", "true"), ), }, }, @@ -149,6 +153,7 @@ func TestUnitModuleResource(t *testing.T) { TagPrefix: updatedModule.TagPrefix, ModuleTestEnabled: updatedModule.ModuleTestEnabled, OpentofuVersion: updatedModule.OpentofuVersion, + IsAzureDevOps: updatedModule.IsAzureDevOps, }).Times(1).Return(&updatedModule, nil) gomock.InOrder(