From 1f8adee68e51d29d8603b1ccf7d0ec04bca3e193 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Wed, 24 Jul 2024 08:53:50 -0500 Subject: [PATCH] Feat: add token_name as a field for data env0_template --- client/template.go | 1 + env0/data_template.go | 20 +++++++++----------- env0/data_template_test.go | 2 ++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/client/template.go b/client/template.go index 9f9e8691..0c7c9bf6 100644 --- a/client/template.go +++ b/client/template.go @@ -63,6 +63,7 @@ type Template struct { HelmChartName string `json:"helmChartName" tfschema:",omitempty"` IsGitLab bool `json:"isGitLab" tfschema:"is_gitlab"` TerragruntTfBinary string `json:"terragruntTfBinary" tfschema:",omitempty"` + TokenName string `json:"tokenName"` } type TemplateCreatePayload struct { diff --git a/env0/data_template.go b/env0/data_template.go index db1a2933..0ca36aba 100644 --- a/env0/data_template.go +++ b/env0/data_template.go @@ -84,12 +84,12 @@ func dataTemplate() *schema.Resource { "github_installation_id": { Type: schema.TypeInt, Description: "The env0 application installation id on the relevant github repository", - Optional: true, + Computed: true, }, "token_id": { Type: schema.TypeString, Description: "The token id used for private git repos or for integration with GitLab", - Optional: true, + Computed: true, }, "terraform_version": { Type: schema.TypeString, @@ -100,58 +100,56 @@ func dataTemplate() *schema.Resource { Type: schema.TypeString, Description: "terragrunt version to use", Computed: true, - Optional: true, }, "is_gitlab_enterprise": { Type: schema.TypeBool, Description: "Does this template use gitlab enterprise repository?", - Optional: true, Computed: true, }, "bitbucket_client_key": { Type: schema.TypeString, Description: "the bitbucket client key used for integration", - Optional: true, Computed: true, }, "is_bitbucket_server": { Type: schema.TypeBool, Description: "true if this template uses bitbucket server repository", - Optional: true, Computed: true, }, "is_github_enterprise": { Type: schema.TypeBool, Description: "true if this template uses github enterprise repository", - 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", - Optional: true, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, Description: "ssh key id", - Required: true, + Computed: true, }, "name": { Type: schema.TypeString, Description: "ssh key name", - Required: true, + Computed: true, }, }, }, }, + "token_name": { + Type: schema.TypeString, + Description: "the token name used for integration with GitLab", + Computed: true, + }, }, } } diff --git a/env0/data_template_test.go b/env0/data_template_test.go index d931b7d6..4f477307 100644 --- a/env0/data_template_test.go +++ b/env0/data_template_test.go @@ -42,6 +42,7 @@ func TestUnitTemplateData(t *testing.T) { }, IsBitbucketServer: true, IsAzureDevOps: true, + TokenName: "tokenname", } getValidTestCase := func(input map[string]interface{}) resource.TestCase { @@ -69,6 +70,7 @@ func TestUnitTemplateData(t *testing.T) { 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"), + resource.TestCheckResourceAttr(resourceFullName, "token_name", template.TokenName), ), }, },