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

Commit9bcdcd6

Browse files
authored
feat: Add legacy_variable_name to parameter (#110)
* feat: Add legacy_variable_name to parameter* fix* fix* Fix
1 parent7c0f341 commit9bcdcd6

File tree

4 files changed

+195
-180
lines changed

4 files changed

+195
-180
lines changed

‎docs/data-sources/parameter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Use this data source to configure editable options for workspaces.
2424
-`default` (String) A default value for the parameter.
2525
-`description` (String) Describe what this parameter does.
2626
-`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>"`.
27-
-`legacy_variable` (String) The name of the Terraform variable used by legacy parameters. Coder will use it to lookup the parameter value.
27+
-`legacy_variable` (String) Reference to the Terraform variable. Coder will use it to lookup the default value.
28+
-`legacy_variable_name` (String) Name of the legacy Terraform variable. Coder will use it to lookup the variable value.
2829
-`mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution!
2930
-`option` (Block List, Max: 64) Each "option" block defines a value for a user to select from. (see[below for nested schema](#nestedblock--option))
3031
-`type` (String) The type of this parameter. Must be one of: "number", "string", or "bool".

‎examples/resources/coder_parameter_migration/resource.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ variable "old_account_name" {
66
}
77

88
data"coder_parameter""account_name" {
9-
name="Account Name"
10-
type="string"
11-
legacy_variable=var.old_account_name
9+
name="Account Name"
10+
type="string"
11+
12+
legacy_variable_name="old_account_name"
13+
legacy_variable=var.old_account_name
1214
}

‎provider/parameter.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ type Parameter struct {
5050
Validation []Validation
5151
Optionalbool
5252

53-
LegacyVariablestring
53+
LegacyVariableNamestring
54+
LegacyVariablestring
5455
}
5556

5657
funcparameterDataSource()*schema.Resource {
@@ -72,7 +73,8 @@ func parameterDataSource() *schema.Resource {
7273
Validationinterface{}
7374
Optionalinterface{}
7475

75-
LegacyVariableinterface{}
76+
LegacyVariableNameinterface{}
77+
LegacyVariableinterface{}
7678
}{
7779
Value:rd.Get("value"),
7880
Name:rd.Get("name"),
@@ -101,7 +103,8 @@ func parameterDataSource() *schema.Resource {
101103
rd.Set("optional",val)
102104
returnval
103105
}(),
104-
LegacyVariable:rd.Get("legacy_variable"),
106+
LegacyVariableName:rd.Get("legacy_variable_name"),
107+
LegacyVariable:rd.Get("legacy_variable"),
105108
},&parameter)
106109
iferr!=nil {
107110
returndiag.Errorf("decode parameter: %s",err)
@@ -297,10 +300,17 @@ func parameterDataSource() *schema.Resource {
297300
Computed:true,
298301
Description:"Whether this value is optional.",
299302
},
303+
"legacy_variable_name": {
304+
Type:schema.TypeString,
305+
Optional:true,
306+
RequiredWith: []string{"legacy_variable"},
307+
Description:"Name of the legacy Terraform variable. Coder will use it to lookup the variable value.",
308+
},
300309
"legacy_variable": {
301-
Type:schema.TypeString,
302-
Optional:true,
303-
Description:"The name of the Terraform variable used by legacy parameters. Coder will use it to lookup the parameter value.",
310+
Type:schema.TypeString,
311+
Optional:true,
312+
RequiredWith: []string{"legacy_variable_name"},
313+
Description:"Reference to the Terraform variable. Coder will use it to lookup the default value.",
304314
},
305315
},
306316
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp