Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit79d6ecd

Browse files
authored
feat: Add display_name to coder_parameter (#118)
1 parentf0da725 commit79d6ecd

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

‎docs/data-sources/parameter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ Use this data source to configure editable options for workspaces.
1717

1818
###Required
1919

20-
-`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.
20+
-`name` (String) The name of the parameter. If this is changed, developers will be re-prompted for a new value.
2121

2222
###Optional
2323

2424
-`default` (String) A default value for the parameter.
2525
-`description` (String) Describe what this parameter does.
26+
-`display_name` (String) The displayed name of the parameter as it will appear in the interface.
2627
-`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>"`.
2728
-`legacy_variable` (String) Reference to the Terraform variable. Coder will use it to lookup the default value.
2829
-`legacy_variable_name` (String) Name of the legacy Terraform variable. Coder will use it to lookup the variable value.

‎examples/resources/coder_parameter/resource.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ data "coder_parameter" "fairy_tale" {
7777
}
7878

7979
data"coder_parameter""users" {
80-
name="System users"
81-
type="list(string)"
82-
default=jsonencode(["root","user1","user2"])
80+
name="system_users"
81+
display_name="System users"
82+
type="list(string)"
83+
default=jsonencode(["root","user1","user2"])
8384
}

‎provider/parameter.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const (
4242
typeParameterstruct {
4343
Valuestring
4444
Namestring
45+
DisplayNamestring
4546
Descriptionstring
4647
Typestring
4748
Mutablebool
@@ -65,6 +66,7 @@ func parameterDataSource() *schema.Resource {
6566
err:=mapstructure.Decode(struct {
6667
Valueinterface{}
6768
Nameinterface{}
69+
DisplayNameinterface{}
6870
Descriptioninterface{}
6971
Typeinterface{}
7072
Mutableinterface{}
@@ -79,6 +81,7 @@ func parameterDataSource() *schema.Resource {
7981
}{
8082
Value:rd.Get("value"),
8183
Name:rd.Get("name"),
84+
DisplayName:rd.Get("display_name"),
8285
Description:rd.Get("description"),
8386
Type:rd.Get("type"),
8487
Mutable:rd.Get("mutable"),
@@ -170,7 +173,12 @@ func parameterDataSource() *schema.Resource {
170173
"name": {
171174
Type:schema.TypeString,
172175
Required:true,
173-
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.",
176+
Description:"The name of the parameter. If this is changed, developers will be re-prompted for a new value.",
177+
},
178+
"display_name": {
179+
Type:schema.TypeString,
180+
Optional:true,
181+
Description:"The displayed name of the parameter as it will appear in the interface.",
174182
},
175183
"description": {
176184
Type:schema.TypeString,

‎provider/parameter_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ func TestParameter(t *testing.T) {
2222
Name:"FieldsExist",
2323
Config:`
2424
data "coder_parameter" "region" {
25-
name = "Region"
25+
name = "region"
26+
display_name = "Region"
2627
type = "string"
2728
description = <<-EOT
2829
# Select the machine image
@@ -47,7 +48,8 @@ func TestParameter(t *testing.T) {
4748
Check:func(state*terraform.ResourceState) {
4849
attrs:=state.Primary.Attributes
4950
forkey,value:=rangemap[string]interface{}{
50-
"name":"Region",
51+
"name":"region",
52+
"display_name":"Region",
5153
"type":"string",
5254
"description":"# Select the machine image\nSee the [registry](https://container.registry.blah/namespace) for options.\n",
5355
"mutable":"true",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp