Skip to content

Commit 5c965e8

Browse files
fix: template version replacement & metadata updates (#58)
1 parent b79d851 commit 5c965e8

File tree

6 files changed

+762
-268
lines changed

6 files changed

+762
-268
lines changed

docs/resources/template.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ A Coder template
2424

2525
- `acl` (Attributes) Access control list for the template. Requires an enterprise Coder deployment. If null, ACL policies will not be added or removed by Terraform. (see [below for nested schema](#nestedatt--acl))
2626
- `activity_bump_ms` (Number) The activity bump duration for all workspaces created from this template, in milliseconds. Defaults to one hour.
27-
- `allow_user_auto_start` (Boolean) Whether users can auto-start workspaces created from this template. Defaults to true.
28-
- `allow_user_auto_stop` (Boolean) Whether users can auto-start workspaces created from this template. Defaults to true.
27+
- `allow_user_auto_start` (Boolean) Whether users can auto-start workspaces created from this template. Defaults to true. Requires an enterprise Coder deployment.
28+
- `allow_user_auto_stop` (Boolean) Whether users can auto-start workspaces created from this template. Defaults to true. Requires an enterprise Coder deployment.
2929
- `allow_user_cancel_workspace_jobs` (Boolean) Whether users can cancel in-progress workspace jobs using this template. Defaults to true.
3030
- `auto_start_permitted_days_of_week` (Set of String) List of days of the week in which autostart is allowed to happen, for all workspaces created from this template. Defaults to all days. If no days are specified, autostart is not allowed. Requires an enterprise Coder deployment.
3131
- `auto_stop_requirement` (Attributes) The auto-stop requirement for all workspaces created from this template. Requires an enterprise Coder deployment. (see [below for nested schema](#nestedatt--auto_stop_requirement))
@@ -55,7 +55,7 @@ Optional:
5555

5656
- `active` (Boolean) Whether this version is the active version of the template. Only one version can be active at a time.
5757
- `message` (String) A message describing the changes in this version of the template. Messages longer than 72 characters will be truncated.
58-
- `name` (String) The name of the template version. Automatically generated if not provided.
58+
- `name` (String) The name of the template version. Automatically generated if not provided. If provided, the name *must* change each time the directory contents are updated.
5959
- `provisioner_tags` (Attributes Set) Provisioner tags for the template version. (see [below for nested schema](#nestedatt--versions--provisioner_tags))
6060
- `tf_vars` (Attributes Set) Terraform variables for the template version. (see [below for nested schema](#nestedatt--versions--tf_vars))
6161

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/hashicorp/terraform-plugin-go v0.23.0
1717
github.com/hashicorp/terraform-plugin-log v0.9.0
1818
github.com/hashicorp/terraform-plugin-testing v1.9.0
19+
github.com/otiai10/copy v1.14.0
1920
github.com/stretchr/testify v1.9.0
2021
)
2122

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQ
339339
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
340340
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
341341
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
342+
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
343+
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
344+
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
345+
github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
342346
github.com/outcaste-io/ristretto v0.2.3 h1:AK4zt/fJ76kjlYObOeNwh4T3asEuaCmp26pOvUOL9w0=
343347
github.com/outcaste-io/ristretto v0.2.3/go.mod h1:W8HywhmtlopSB1jeMg3JtdIhf+DYkLAr0VN/s4+MHac=
344348
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=

integration/template-test/main.tf

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ terraform {
77
}
88
}
99

10+
provider "coderd" {
11+
url = "http://localhost:3000"
12+
token = "NbRNSwdzeb-Npwlm9TIOX3bpEQIsgt2KI"
13+
}
14+
1015
resource "coderd_user" "ethan" {
11-
username = "ethan"
12-
name = "Ethan Coolguy"
13-
email = "test@coder.com"
16+
username = "dean"
17+
name = "Dean Coolguy"
18+
email = "deantest@coder.com"
1419
roles = ["owner", "template-admin"]
1520
login_type = "password"
1621
password = "SomeSecurePassword!"
@@ -41,8 +46,7 @@ resource "coderd_template" "sample" {
4146
}
4247
versions = [
4348
{
44-
name = "latest"
45-
directory = "./example-template"
49+
directory = "./example-template-2"
4650
active = true
4751
tf_vars = [
4852
{
@@ -52,7 +56,6 @@ resource "coderd_template" "sample" {
5256
]
5357
},
5458
{
55-
name = "legacy"
5659
directory = "./example-template-2"
5760
active = false
5861
tf_vars = [

0 commit comments

Comments
 (0)