Skip to content

Commit

Permalink
Feat: support newly added template types - pulumi, k8s & workflow (#428)
Browse files Browse the repository at this point in the history
* Feat: support newly added template types - pulumi, k8s & workflow

* fixed unit test

* modify comple to workflow
  • Loading branch information
TomerHeber committed Jun 26, 2022
1 parent 8027c94 commit a3036c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion env0/data_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package env0

import (
"context"
"fmt"
"strings"

"github.com/env0/terraform-provider-env0/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -42,7 +44,7 @@ func dataTemplate() *schema.Resource {
},
"type": {
Type: schema.TypeString,
Description: "'terraform' or 'terragrunt'",
Description: fmt.Sprintf("template type (allowed values: %s)", strings.Join(allowedTemplateTypes, ", ")),
Computed: true,
},
"project_ids": {
Expand Down
2 changes: 1 addition & 1 deletion env0/resource_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ func TestUnitTemplateResource(t *testing.T) {
"repository": template.Repository,
"type": "gruntyform",
}),
ExpectError: regexp.MustCompile(`must be one of: terragrunt, terraform`),
ExpectError: regexp.MustCompile(`must be one of`),
},
},
}
Expand Down
14 changes: 12 additions & 2 deletions env0/templates.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package env0

import (
"fmt"
"sort"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand All @@ -13,6 +15,14 @@ const (
TemplateTypeShared = 2
)

var allowedTemplateTypes = []string{
"terraform",
"terragrunt",
"pulumi",
"k8s",
"workflow",
}

func getTemplateSchema(templateType TemplateType) map[string]*schema.Schema {
/*
* VCS Constraints:
Expand Down Expand Up @@ -78,10 +88,10 @@ func getTemplateSchema(templateType TemplateType) map[string]*schema.Schema {
},
"type": {
Type: schema.TypeString,
Description: "'terraform' or 'terragrunt'",
Description: fmt.Sprintf("template type (allowed values: %s)", strings.Join(allowedTemplateTypes, ", ")),
Optional: true,
Default: "terraform",
ValidateDiagFunc: NewStringInValidator([]string{"terragrunt", "terraform"}),
ValidateDiagFunc: NewStringInValidator(allowedTemplateTypes),
},
"ssh_keys": {
Type: schema.TypeList,
Expand Down

0 comments on commit a3036c8

Please sign in to comment.