- Notifications
You must be signed in to change notification settings - Fork23
feat: add icon and description fields to workspace preset#422
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
c9a6321
6a4d070
fac00c7
d2efd30
6c22150
2a17ccc
23765b0
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -20,8 +20,10 @@ data "coder_parameter" "param" { | ||
icon = "param icon" | ||
} | ||
data "coder_workspace_preset" "preset" { | ||
name = "preset" | ||
description = "preset description" | ||
icon = "preset icon" | ||
Comment on lines +23 to +25 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. nit: should we use rather realistic values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I followed the naming convention used by the other parameters, as they follow a similar logic. Since this is an integration test, I don’t think adding realistic values here is necessary. | ||
default = true | ||
parameters = { | ||
(data.coder_parameter.param.name) = "preset param value" | ||
} | ||
@@ -65,6 +67,8 @@ locals { | ||
"workspace_parameter.value" : data.coder_parameter.param.value, | ||
"workspace_parameter.icon" : data.coder_parameter.param.icon, | ||
"workspace_preset.name" : data.coder_workspace_preset.preset.name, | ||
"workspace_preset.description" : data.coder_workspace_preset.preset.description, | ||
"workspace_preset.icon" : data.coder_workspace_preset.preset.icon, | ||
"workspace_preset.default" : tostring(data.coder_workspace_preset.preset.default), | ||
"workspace_preset.parameters.param" : data.coder_workspace_preset.preset.parameters.param, | ||
"workspace_preset.prebuilds.instances" : tostring(one(data.coder_workspace_preset.preset.prebuilds).instances), | ||
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -18,9 +18,11 @@ import ( | ||||||||||||
var PrebuildsCRONParser = rbcron.NewParser(rbcron.Minute | rbcron.Hour | rbcron.Dom | rbcron.Month | rbcron.Dow) | ||||||||||||
type WorkspacePreset struct { | ||||||||||||
Name string `mapstructure:"name"` | ||||||||||||
Description string `mapstructure:"description"` | ||||||||||||
Icon string `mapstructure:"icon"` | ||||||||||||
Default bool `mapstructure:"default"` | ||||||||||||
Parameters map[string]string `mapstructure:"parameters"` | ||||||||||||
// There should always be only one prebuild block, but Terraform's type system | ||||||||||||
// still parses them as a slice, so we need to handle it as such. We could use | ||||||||||||
// an anonymous type and rd.Get to avoid a slice here, but that would not be possible | ||||||||||||
@@ -93,6 +95,24 @@ func workspacePresetDataSource() *schema.Resource { | ||||||||||||
Required: true, | ||||||||||||
ValidateFunc: validation.StringIsNotEmpty, | ||||||||||||
}, | ||||||||||||
"description": { | ||||||||||||
ContributorAuthor
|
"description": { | |
Type:schema.TypeString, | |
Optional:true, | |
Description:"Describe what this parameter does.", | |
}, |
I think it would make sense to add reasonable size limits to both description and icon, similar to what we do fortemplates
table:
- description (128):https://github.com/coder/coder/blob/main/coderd/database/dump.sql#L1727
- icon (256):https://github.com/coder/coder/blob/dd2fb896eb90406c606f21e09cdd7680821542e7/coderd/database/dump.sql#L1730
Wdyt?
What do you mean by 'local' here? The icon is used by the UI, and the icons are generally hosted on the control plane, although I've seen people link to icons on other domains.
By "local" I meant relative paths like/icon/region.svg
. Given that, someone could technically enter a path like../../etc/passwd
or something similar.
Where specifically have you checked?
I tested the integration between the Terraform provider and Coder. I inserted a description with inline JavaScript and confirmed it was passed through and stored in the database. However, from my quick test, the UI seems to display the content as plain text and doesn’t interpret or render it as raw HTML, so that is good. I didn't test the icon path.
Template admins have a good bit of power in a Coder deployment, so there is some element of trust related to allowing users to create templates.
Totally agree. Given Coder is self-hosted and template creation is an admin-level task, I don't think this is a critical issue, more of an observation from working on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it would make sense to add reasonable size limits to both description and icon, similar to what we do for templates table
I think that's reasonable!
By "local" I meant relative paths like /icon/region.svg. Given that, someone could technically enter a path like ../../etc/passwd or something similar.
Right, but I don't think we would expose that in our static file server though. Might be no harm to sanitize the path though, good callout!
Uh oh!
There was an error while loading.Please reload this page.