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

Commit5d01ad6

Browse files
authored
feat: drop support for legacy variables (#140)
1 parentabc4f98 commit5d01ad6

File tree

9 files changed

+15
-138
lines changed

9 files changed

+15
-138
lines changed

‎docs/data-sources/parameter.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ Use this data source to configure editable options for workspaces.
2626
-`display_name` (String) The displayed name of the parameter as it will appear in the interface.
2727
-`ephemeral` (Boolean) The value of an ephemeral parameter will not be preserved between consecutive workspace builds.
2828
-`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>"`.
29-
-`legacy_variable` (String, Deprecated) Reference to the Terraform variable. Coder will use it to lookup the default value.
30-
-`legacy_variable_name` (String, Deprecated) Name of the legacy Terraform variable. Coder will use it to lookup the variable value.
3129
-`mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution!
3230
-`option` (Block List, Max: 64) Each "option" block defines a value for a user to select from. (see[below for nested schema](#nestedblock--option))
3331
-`order` (Number) The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order).

‎docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ resource "google_compute_instance" "dev" {
6262

6363
###Optional
6464

65-
-`feature_use_managed_variables` (Boolean) Feature: use managed Terraform variables.If disabled,Terraform variableswill be included in legacy Parameter Schema.
65+
-`feature_use_managed_variables` (Boolean, Deprecated) Feature: use managed Terraform variables.The feature flag is not used anymore asTerraform variablesare now exclusively utilized for template-wide variables.
6666
-`url` (String) The URL to access Coder.

‎examples/resources/coder_parameter/resource.tf‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
provider"coder" {
2-
feature_use_managed_variables=true
3-
}
1+
provider"coder" {}
42

53
data"coder_parameter""example" {
64
name="Region"

‎examples/resources/coder_parameter_migration/resource.tf‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎provider/decode_test.go‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@ import (
1111
)
1212

1313
funcTestDecode(t*testing.T) {
14-
const (
15-
legacyVariable="Legacy Variable"
16-
legacyVariableName="Legacy Variable Name"
17-
18-
displayName="Display Name"
19-
)
14+
constdisplayName="Display Name"
2015

2116
aMap:=map[string]interface{}{
22-
"name":"Parameter Name",
23-
"type":"number",
24-
"display_name":displayName,
25-
"legacy_variable":legacyVariable,
26-
"legacy_variable_name":legacyVariableName,
17+
"name":"Parameter Name",
18+
"type":"number",
19+
"display_name":displayName,
2720
"validation": []map[string]interface{}{
2821
{
2922
"min":nil,
@@ -38,8 +31,6 @@ func TestDecode(t *testing.T) {
3831
err:=mapstructure.Decode(aMap,&param)
3932
require.NoError(t,err)
4033
assert.Equal(t,displayName,param.DisplayName)
41-
assert.Equal(t,legacyVariable,param.LegacyVariable)
42-
assert.Equal(t,legacyVariableName,param.LegacyVariableName)
4334
assert.Equal(t,5,param.Validation[0].Max)
4435
assert.True(t,param.Validation[0].MaxDisabled)
4536
assert.Equal(t,0,param.Validation[0].Min)

‎provider/examples_test.go‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ func TestExamples(t *testing.T) {
2626
}},
2727
})
2828
})
29-
30-
t.Run("coder_parameter_migration",func(t*testing.T) {
31-
t.Parallel()
32-
33-
resource.Test(t, resource.TestCase{
34-
Providers:map[string]*schema.Provider{
35-
"coder":provider.New(),
36-
},
37-
IsUnitTest:true,
38-
Steps: []resource.TestStep{{
39-
Config:mustReadFile(t,"../examples/resources/coder_parameter_migration/resource.tf"),
40-
}},
41-
})
42-
})
4329
}
4430

4531
funcmustReadFile(t*testing.T,pathstring)string {

‎provider/parameter.go‎

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ type Parameter struct {
5858
Optionalbool
5959
Orderint
6060
Ephemeralbool
61-
62-
LegacyVariableNamestring`mapstructure:"legacy_variable_name"`
63-
LegacyVariablestring`mapstructure:"legacy_variable"`
6461
}
6562

6663
funcparameterDataSource()*schema.Resource {
@@ -94,30 +91,17 @@ func parameterDataSource() *schema.Resource {
9491
Optionalinterface{}
9592
Orderinterface{}
9693
Ephemeralinterface{}
97-
98-
LegacyVariableNameinterface{}
99-
LegacyVariableinterface{}
10094
}{
10195
Value:rd.Get("value"),
10296
Name:rd.Get("name"),
10397
DisplayName:rd.Get("display_name"),
10498
Description:rd.Get("description"),
10599
Type:rd.Get("type"),
106100
Mutable:rd.Get("mutable"),
107-
Default:func()interface{} {
108-
standardMode:=rd.GetRawConfig().AsValueMap()["legacy_variable"].IsNull()
109-
ifstandardMode {
110-
returnrd.Get("default")
111-
}
112-
113-
// legacy variable is linked
114-
legacyVariable:=rd.GetRawConfig().AsValueMap()["legacy_variable"].AsString()
115-
rd.Set("default",legacyVariable)
116-
returnlegacyVariable
117-
}(),
118-
Icon:rd.Get("icon"),
119-
Option:rd.Get("option"),
120-
Validation:fixedValidation,
101+
Default:rd.Get("default"),
102+
Icon:rd.Get("icon"),
103+
Option:rd.Get("option"),
104+
Validation:fixedValidation,
121105
Optional:func()bool {
122106
// This hack allows for checking if the "default" field is present in the .tf file.
123107
// If "default" is missing or is "null", then it means that this field is required,
@@ -126,10 +110,8 @@ func parameterDataSource() *schema.Resource {
126110
rd.Set("optional",val)
127111
returnval
128112
}(),
129-
Order:rd.Get("order"),
130-
Ephemeral:rd.Get("ephemeral"),
131-
LegacyVariableName:rd.Get("legacy_variable_name"),
132-
LegacyVariable:rd.Get("legacy_variable"),
113+
Order:rd.Get("order"),
114+
Ephemeral:rd.Get("ephemeral"),
133115
},&parameter)
134116
iferr!=nil {
135117
returndiag.Errorf("decode parameter: %s",err)
@@ -352,20 +334,6 @@ func parameterDataSource() *schema.Resource {
352334
Optional:true,
353335
Description:"The value of an ephemeral parameter will not be preserved between consecutive workspace builds.",
354336
},
355-
"legacy_variable_name": {
356-
Type:schema.TypeString,
357-
Optional:true,
358-
RequiredWith: []string{"legacy_variable"},
359-
Description:"Name of the legacy Terraform variable. Coder will use it to lookup the variable value.",
360-
Deprecated:"Effective from Coder v0.24.0, the parameter migration feature is no longer available. This attribute will be removed in the nearest future.",
361-
},
362-
"legacy_variable": {
363-
Type:schema.TypeString,
364-
Optional:true,
365-
RequiredWith: []string{"legacy_variable_name"},
366-
Description:"Reference to the Terraform variable. Coder will use it to lookup the default value.",
367-
Deprecated:"Effective from Coder v0.24.0, the parameter migration feature is no longer available. This attribute will be removed in the nearest future.",
368-
},
369337
},
370338
}
371339
}

‎provider/parameter_test.go‎

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -353,32 +353,6 @@ func TestParameter(t *testing.T) {
353353
require.Equal(t,expected,state.Primary.Attributes[key])
354354
}
355355
},
356-
}, {
357-
Name:"LegacyVariable",
358-
Config:`
359-
variable "old_region" {
360-
type = string
361-
default = "fake-region" # for testing purposes, no need to set via env TF_...
362-
}
363-
364-
data "coder_parameter" "region" {
365-
name = "Region"
366-
type = "string"
367-
default = "will-be-ignored"
368-
legacy_variable_name = "old_region"
369-
legacy_variable = var.old_region
370-
}`,
371-
Check:func(state*terraform.ResourceState) {
372-
forkey,expected:=rangemap[string]string{
373-
"name":"Region",
374-
"type":"string",
375-
"default":"fake-region",
376-
"legacy_variable_name":"old_region",
377-
"legacy_variable":"fake-region",
378-
} {
379-
require.Equal(t,expected,state.Primary.Attributes[key])
380-
}
381-
},
382356
}, {
383357
Name:"ListOfStrings",
384358
Config:`
@@ -398,32 +372,6 @@ data "coder_parameter" "region" {
398372
require.Equal(t,expected,attributeValue)
399373
}
400374
},
401-
}, {
402-
Name:"ListOfStringsButMigrated",
403-
Config:`
404-
variable "old_region" {
405-
type = list(string)
406-
default = ["us-west-1a"] # for testing purposes, no need to set via env TF_...
407-
}
408-
409-
data "coder_parameter" "region" {
410-
name = "Region"
411-
type = "list(string)"
412-
default = "[\"us-east-1\", \"eu-west-1\", \"ap-northeast-1\"]"
413-
legacy_variable_name = "old_region"
414-
legacy_variable = jsonencode(var.old_region)
415-
}`,
416-
Check:func(state*terraform.ResourceState) {
417-
forkey,expected:=rangemap[string]string{
418-
"name":"Region",
419-
"type":"list(string)",
420-
"default":`["us-west-1a"]`,
421-
} {
422-
attributeValue,ok:=state.Primary.Attributes[key]
423-
require.True(t,ok,"attribute %q is expected",key)
424-
require.Equal(t,expected,attributeValue)
425-
}
426-
},
427375
}, {
428376
Name:"NumberValidation_Max",
429377
Config:`

‎provider/provider.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ func New() *schema.Provider {
3737
},
3838
"feature_use_managed_variables": {
3939
Type:schema.TypeBool,
40-
Description:"Feature: use managed Terraform variables. If disabled, Terraform variables will be included in legacy Parameter Schema.",
40+
Description:"Feature: use managed Terraform variables. The feature flag is not used anymore as Terraform variables are now exclusively utilized for template-wide variables.",
41+
Default:true,
4142
Optional:true,
43+
Deprecated:"Terraform variables are now exclusively utilized for template-wide variables after the removal of support for legacy parameters.",
4244
},
4345
},
4446
ConfigureContextFunc:func(c context.Context,resourceData*schema.ResourceData) (interface{}, diag.Diagnostics) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp