Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: chore!: use map over list for template tf_vars & provisioner_tags #124

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ resource "coderd_template" "example" {
versions = [{
directory = "./example-template"
active = true
tf_vars = [{
name = "image_id"
value = "ami-12345678"
}]
tf_vars = {
"image_id" = "ami-12345678"
}
# Version names can be randomly generated if null/omitted
}]
acl = {
Expand Down
22 changes: 2 additions & 20 deletions docs/resources/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,14 @@ Optional:
- `active` (Boolean) Whether this version is the active version of the template. Only one version can be active at a time.
- `message` (String) A message describing the changes in this version of the template. Messages longer than 72 characters will be truncated.
- `name` (String) The name of the template version. Automatically generated if not provided. If provided, the name *must* change each time the directory contents, or the `tf_vars` attribute are updated.
- `provisioner_tags` (Attributes Set) Provisioner tags for the template version. (see [below for nested schema](#nestedatt--versions--provisioner_tags))
- `tf_vars` (Attributes Set) Terraform variables for the template version. (see [below for nested schema](#nestedatt--versions--tf_vars))
- `provisioner_tags` (Map of String) Provisioner tags for the template version.
- `tf_vars` (Map of String) Terraform variables for the template version.

Read-Only:

- `directory_hash` (String)
- `id` (String)

<a id="nestedatt--versions--provisioner_tags"></a>
### Nested Schema for `versions.provisioner_tags`

Required:

- `name` (String)
- `value` (String)


<a id="nestedatt--versions--tf_vars"></a>
### Nested Schema for `versions.tf_vars`

Required:

- `name` (String)
- `value` (String)



<a id="nestedatt--acl"></a>
### Nested Schema for `acl`
Expand Down
7 changes: 3 additions & 4 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ resource "coderd_template" "example" {
versions = [{
directory = "./example-template"
active = true
tf_vars = [{
name = "image_id"
value = "ami-12345678"
}]
tf_vars = {
"image_id" = "ami-12345678"
}
# Version names can be randomly generated if null/omitted
}]
acl = {
Expand Down
18 changes: 6 additions & 12 deletions integration/template-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,16 @@ resource "coderd_template" "sample" {
{
directory = "./example-template-2"
active = true
tf_vars = [
{
name = "name"
value = "world"
},
]
tf_vars = {
name = "world"
}
},
{
directory = "./example-template-2"
active = false
tf_vars = [
{
name = "name"
value = "ethan"
},
]
tf_vars = {
name = "ethan"
}
}
]
}
Expand Down
7 changes: 2 additions & 5 deletions internal/provider/template_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ func TestAccTemplateDataSource(t *testing.T) {
Name: types.StringValue("main"),
Message: types.StringValue("Initial commit"),
Directory: types.StringValue("../../integration/template-test/example-template/"),
TerraformVariables: []Variable{
{
Name: types.StringValue("name"),
Value: types.StringValue("world"),
},
TerraformVariables: map[string]string{
"name": "world",
},
},
})
Expand Down
Loading
Loading