Skip to content

Commit

Permalink
Feat: is_azure_devops property is not included in data.template and m…
Browse files Browse the repository at this point in the history
…odule resource (#846)
  • Loading branch information
TomerHeber committed May 7, 2024
1 parent a25b8f0 commit 28d2399
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions env0/data_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions env0/data_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestModuleDataSource(t *testing.T) {
TokenId: "t0",
TokenName: "n0",
Repository: "r0",
IsAzureDevOps: true,
}

otherModule := client.Module{
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down
6 changes: 6 additions & 0 deletions env0/data_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions env0/data_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"),
),
},
},
Expand Down
6 changes: 6 additions & 0 deletions env0/resource_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
}
Expand Down
5 changes: 5 additions & 0 deletions env0/resource_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"),
),
},
{
Expand All @@ -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),
Expand All @@ -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"),
),
},
},
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 28d2399

Please sign in to comment.