Skip to content

Commit

Permalink
fixes based on CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Jun 11, 2023
1 parent d021111 commit 72008cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 10 additions & 0 deletions client/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
17 changes: 9 additions & 8 deletions env0/resource_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func getTemplateSchema(prefix string) map[string]*schema.Schema {
"is_azure_devops",
"helm_chart_name",
"is_helm_repository",
"path",

This comment has been minimized.

Copy link
@TomerHeber

TomerHeber Jun 11, 2023

Author Collaborator

added "path" to the list of attributes to check for conflicts.
If used with "is_helm_repository" or "helm_chart_name" will cause a conflict in the schema.

}

allVCSAttributesBut := func(strs ...string) []string {
Expand Down Expand Up @@ -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": {
Expand All @@ -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,
Expand All @@ -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": {
Expand Down

0 comments on commit 72008cc

Please sign in to comment.