Skip to content

feat: Add display_name to coder_parameter #118

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

Merged
merged 1 commit into from
Mar 31, 2023
Merged
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
3 changes: 2 additions & 1 deletion docs/data-sources/parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ Use this data source to configure editable options for workspaces.

### Required

- `name` (String) The name of the parameter as it will appear in the interface. If this is changed, developers will be re-prompted for a new value.
- `name` (String) The name of the parameter. If this is changed, developers will be re-prompted for a new value.

### Optional

- `default` (String) A default value for the parameter.
- `description` (String) Describe what this parameter does.
- `display_name` (String) The displayed name of the parameter as it will appear in the interface.
- `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>"`.
- `legacy_variable` (String) Reference to the Terraform variable. Coder will use it to lookup the default value.
- `legacy_variable_name` (String) Name of the legacy Terraform variable. Coder will use it to lookup the variable value.
Expand Down
7 changes: 4 additions & 3 deletions examples/resources/coder_parameter/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ data "coder_parameter" "fairy_tale" {
}

data "coder_parameter" "users" {
name = "System users"
type = "list(string)"
default = jsonencode(["root", "user1", "user2"])
name = "system_users"
display_name = "System users"
type = "list(string)"
default = jsonencode(["root", "user1", "user2"])
}
10 changes: 9 additions & 1 deletion provider/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
type Parameter struct {
Value string
Name string
DisplayName string
Description string
Type string
Mutable bool
Expand All @@ -65,6 +66,7 @@ func parameterDataSource() *schema.Resource {
err := mapstructure.Decode(struct {
Value interface{}
Name interface{}
DisplayName interface{}
Description interface{}
Type interface{}
Mutable interface{}
Expand All @@ -79,6 +81,7 @@ func parameterDataSource() *schema.Resource {
}{
Value: rd.Get("value"),
Name: rd.Get("name"),
DisplayName: rd.Get("display_name"),
Description: rd.Get("description"),
Type: rd.Get("type"),
Mutable: rd.Get("mutable"),
Expand Down Expand Up @@ -170,7 +173,12 @@ func parameterDataSource() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
Description: "The name of the parameter as it will appear in the interface. If this is changed, developers will be re-prompted for a new value.",
Description: "The name of the parameter. If this is changed, developers will be re-prompted for a new value.",
},
"display_name": {
Type: schema.TypeString,
Optional: true,
Description: "The displayed name of the parameter as it will appear in the interface.",
},
"description": {
Type: schema.TypeString,
Expand Down
6 changes: 4 additions & 2 deletions provider/parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func TestParameter(t *testing.T) {
Name: "FieldsExist",
Config: `
data "coder_parameter" "region" {
name = "Region"
name = "region"
display_name = "Region"
type = "string"
description = <<-EOT
# Select the machine image
Expand All @@ -47,7 +48,8 @@ func TestParameter(t *testing.T) {
Check: func(state *terraform.ResourceState) {
attrs := state.Primary.Attributes
for key, value := range map[string]interface{}{
"name": "Region",
"name": "region",
"display_name": "Region",
"type": "string",
"description": "# Select the machine image\nSee the [registry](https://container.registry.blah/namespace) for options.\n",
"mutable": "true",
Expand Down