diff --git a/client/template.go b/client/template.go index 5211f0bc..1cc93355 100644 --- a/client/template.go +++ b/client/template.go @@ -144,6 +144,16 @@ func (payload TemplateCreatePayload) Validate() error { return fmt.Errorf("file_name cannot be set when template type is: %s", payload.Type) } + if payload.IsHelmRepository { + if payload.Type != "helm" { + return errors.New(`can't set is_helm_repository to "true" for non-helm template`) + } + + if payload.HelmChartName == "" { + return errors.New("helm_chart_name is required with helm repository") + } + } + return nil } diff --git a/env0/resource_template.go b/env0/resource_template.go index 8ff4f3fe..b97f2af6 100644 --- a/env0/resource_template.go +++ b/env0/resource_template.go @@ -36,6 +36,7 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema { "is_azure_devops", "helm_chart_name", "is_helm_repository", + "path", } allVCSAttributesBut := func(strs ...string) []string { @@ -137,19 +138,19 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema { Type: schema.TypeInt, Description: "the env0 application installation id on the relevant github repository", Optional: true, - ConflictsWith: allVCSAttributesBut("github_installation_id"), + ConflictsWith: allVCSAttributesBut("github_installation_id", "path"), }, "token_id": { Type: schema.TypeString, Description: "the git token id to be used", Optional: true, - ConflictsWith: allVCSAttributesBut("token_id", "gitlab_project_id", "is_azure_devops"), + ConflictsWith: allVCSAttributesBut("token_id", "gitlab_project_id", "is_azure_devops", "path"), }, "gitlab_project_id": { Type: schema.TypeInt, Description: "the project id of the relevant repository", Optional: true, - ConflictsWith: allVCSAttributesBut("token_id", "gitlab_project_id"), + ConflictsWith: allVCSAttributesBut("token_id", "gitlab_project_id", "path"), RequiredWith: requiredWith("token_id"), }, "terraform_version": { @@ -170,27 +171,27 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema { Description: "true if this template uses gitlab enterprise repository", Optional: true, Default: "false", - ConflictsWith: allVCSAttributesBut("is_gitlab_enterprise"), + ConflictsWith: allVCSAttributesBut("is_gitlab_enterprise", "path"), }, "bitbucket_client_key": { Type: schema.TypeString, Description: "the bitbucket client key used for integration", Optional: true, - ConflictsWith: allVCSAttributesBut("bitbucket_client_key"), + ConflictsWith: allVCSAttributesBut("bitbucket_client_key", "path"), }, "is_bitbucket_server": { Type: schema.TypeBool, Description: "true if this template uses bitbucket server repository", Optional: true, Default: "false", - ConflictsWith: allVCSAttributesBut("is_bitbucket_server"), + ConflictsWith: allVCSAttributesBut("is_bitbucket_server", "path"), }, "is_github_enterprise": { Type: schema.TypeBool, Description: "true if this template uses github enterprise repository", Optional: true, Default: "false", - ConflictsWith: allVCSAttributesBut("is_github_enterprise"), + ConflictsWith: allVCSAttributesBut("is_github_enterprise", "path"), }, "file_name": { Type: schema.TypeString, @@ -208,7 +209,7 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema { Optional: true, Description: "true if this template integrates with azure dev ops", Default: "false", - ConflictsWith: allVCSAttributesBut("is_azure_devops", "token_id"), + ConflictsWith: allVCSAttributesBut("is_azure_devops", "token_id", "path"), RequiredWith: requiredWith("token_id"), }, "helm_chart_name": {