Skip to content

Commit 5ab89ee

Browse files
committed
chore!: use map over list for template tf_vars & provisioner_tags
1 parent 9321b39 commit 5ab89ee

File tree

7 files changed

+816
-326
lines changed

7 files changed

+816
-326
lines changed

docs/index.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ resource "coderd_template" "example" {
5858
versions = [{
5959
directory = "./example-template"
6060
active = true
61-
tf_vars = [{
62-
name = "image_id"
63-
value = "ami-12345678"
64-
}]
61+
tf_vars = {
62+
"image_id" = "ami-12345678"
63+
}
6564
# Version names can be randomly generated if null/omitted
6665
}]
6766
acl = {

docs/resources/template.md

+2-20
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,14 @@ Optional:
100100
- `active` (Boolean) Whether this version is the active version of the template. Only one version can be active at a time.
101101
- `message` (String) A message describing the changes in this version of the template. Messages longer than 72 characters will be truncated.
102102
- `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.
103-
- `provisioner_tags` (Attributes Set) Provisioner tags for the template version. (see [below for nested schema](#nestedatt--versions--provisioner_tags))
104-
- `tf_vars` (Attributes Set) Terraform variables for the template version. (see [below for nested schema](#nestedatt--versions--tf_vars))
103+
- `provisioner_tags` (Map of String) Provisioner tags for the template version.
104+
- `tf_vars` (Map of String) Terraform variables for the template version.
105105

106106
Read-Only:
107107

108108
- `directory_hash` (String)
109109
- `id` (String)
110110

111-
<a id="nestedatt--versions--provisioner_tags"></a>
112-
### Nested Schema for `versions.provisioner_tags`
113-
114-
Required:
115-
116-
- `name` (String)
117-
- `value` (String)
118-
119-
120-
<a id="nestedatt--versions--tf_vars"></a>
121-
### Nested Schema for `versions.tf_vars`
122-
123-
Required:
124-
125-
- `name` (String)
126-
- `value` (String)
127-
128-
129111

130112
<a id="nestedatt--acl"></a>
131113
### Nested Schema for `acl`

examples/provider/provider.tf

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ resource "coderd_template" "example" {
3838
versions = [{
3939
directory = "./example-template"
4040
active = true
41-
tf_vars = [{
42-
name = "image_id"
43-
value = "ami-12345678"
44-
}]
41+
tf_vars = {
42+
"image_id" = "ami-12345678"
43+
}
4544
# Version names can be randomly generated if null/omitted
4645
}]
4746
acl = {

integration/template-test/main.tf

+6-12
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,16 @@ resource "coderd_template" "sample" {
4343
{
4444
directory = "./example-template-2"
4545
active = true
46-
tf_vars = [
47-
{
48-
name = "name"
49-
value = "world"
50-
},
51-
]
46+
tf_vars = {
47+
name = "world"
48+
}
5249
},
5350
{
5451
directory = "./example-template-2"
5552
active = false
56-
tf_vars = [
57-
{
58-
name = "name"
59-
value = "ethan"
60-
},
61-
]
53+
tf_vars = {
54+
name = "ethan"
55+
}
6256
}
6357
]
6458
}

internal/provider/template_data_source_test.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ func TestAccTemplateDataSource(t *testing.T) {
3434
Name: types.StringValue("main"),
3535
Message: types.StringValue("Initial commit"),
3636
Directory: types.StringValue("../../integration/template-test/example-template/"),
37-
TerraformVariables: []Variable{
38-
{
39-
Name: types.StringValue("name"),
40-
Value: types.StringValue("world"),
41-
},
37+
TerraformVariables: map[string]string{
38+
"name": "world",
4239
},
4340
},
4441
})

0 commit comments

Comments
 (0)