You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add icon and description fields to workspace preset (#422)
* feat: add icon and description fields to workspace preset
* chore: update preset.icon to use ValidateURL
* docs: add description and icon to preset examples
* chore: run make fmt
* chore: run make gen
* chore: add size limit to preset icon and description
@@ -49,6 +53,8 @@ data "coder_workspace_preset" "standard" {
49
53
### Optional
50
54
51
55
-`default` (Boolean) Whether this preset should be selected by default when creating a workspace. Only one preset per template can be marked as default.
56
+
-`description` (String) Describe what this preset does.
57
+
-`icon` (String) A URL to an icon that will display in the dashboard. View built-in icons [here](https://github.com/coder/coder/tree/main/site/static/icon). Use a built-in icon with `"${data.coder_workspace.me.access_url}/icon/<path>"`.
52
58
-`parameters` (Map of String) Workspace parameters that will be set by the workspace preset. For simple templates that only need prebuilds, you may define a preset with zero parameters. Because workspace parameters may change between Coder template versions, preset parameters are allowed to define values for parameters that do not exist in the current template version.
53
59
-`prebuilds` (Block Set, Max: 1) Configuration for prebuilt workspaces associated with this preset. Coder will maintain a pool of standby workspaces based on this configuration. When a user creates a workspace using this preset, they are assigned a prebuilt workspace instead of waiting for a new one to build. See prebuilt workspace documentation [here](https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces.md) (see [below for nested schema](#nestedblock--prebuilds))
// So we test it here to make sure we don't regress.
77
84
ExpectError: regexp.MustCompile("Incorrect attribute value type"),
78
85
},
86
+
{
87
+
Name: "Description field is empty",
88
+
Config: `
89
+
data "coder_workspace_preset" "preset_1" {
90
+
name = "preset_1"
91
+
description = ""
92
+
parameters = {
93
+
"region" = "us-east1-a"
94
+
}
95
+
}`,
96
+
// This validation is done by Terraform, but it could still break if we misconfigure the schema.
97
+
// So we test it here to make sure we don't regress.
98
+
ExpectError: nil,
99
+
},
100
+
{
101
+
Name: "Description field exceeds maximum supported length (128 characters)",
102
+
Config: `
103
+
data "coder_workspace_preset" "preset_1" {
104
+
name = "preset_1"
105
+
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vehicula leo sit amet mi laoreet, sed ornare velit tincidunt. Proin gravida lacinia blandit."
106
+
parameters = {
107
+
"region" = "us-east1-a"
108
+
}
109
+
}`,
110
+
// This validation is done by Terraform, but it could still break if we misconfigure the schema.
111
+
// So we test it here to make sure we don't regress.
112
+
ExpectError: regexp.MustCompile(`expected length of description to be in the range \(0 - 128\)`),
113
+
},
114
+
{
115
+
Name: "Icon field is empty",
116
+
Config: `
117
+
data "coder_workspace_preset" "preset_1" {
118
+
name = "preset_1"
119
+
icon = ""
120
+
parameters = {
121
+
"region" = "us-east1-a"
122
+
}
123
+
}`,
124
+
// This validation is done by Terraform, but it could still break if we misconfigure the schema.
125
+
// So we test it here to make sure we don't regress.
126
+
ExpectError: nil,
127
+
},
128
+
{
129
+
Name: "Icon field is an invalid URL",
130
+
Config: `
131
+
data "coder_workspace_preset" "preset_1" {
132
+
name = "preset_1"
133
+
icon = "/icon%.svg"
134
+
parameters = {
135
+
"region" = "us-east1-a"
136
+
}
137
+
}`,
138
+
// This validation is done by Terraform, but it could still break if we misconfigure the schema.
139
+
// So we test it here to make sure we don't regress.
0 commit comments