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

feat: Add legacy_variable_name to parameter#110

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

Merged
mtojek merged 4 commits intocoder:mainfrommtojek:6368-legacy-variable-name
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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 deletiondocs/data-sources/parameter.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,8 @@ Use this data source to configure editable options for workspaces.
- `default` (String) A default value for the parameter.
- `description` (String) Describe what this parameter does.
- `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) The name of the Terraform variable used by legacy parameters. Coder will use it to lookup the parameter value.
- `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.
- `mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution!
- `option` (Block List, Max: 64) Each "option" block defines a value for a user to select from. (see [below for nested schema](#nestedblock--option))
- `type` (String) The type of this parameter. Must be one of: "number", "string", or "bool".
Expand Down
8 changes: 5 additions & 3 deletionsexamples/resources/coder_parameter_migration/resource.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,9 @@ variable "old_account_name" {
}

data "coder_parameter" "account_name" {
name = "Account Name"
type = "string"
legacy_variable = var.old_account_name
name = "Account Name"
type = "string"

legacy_variable_name = "old_account_name"
legacy_variable = var.old_account_name
}
22 changes: 16 additions & 6 deletionsprovider/parameter.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,7 +50,8 @@ type Parameter struct {
Validation []Validation
Optional bool

LegacyVariable string
LegacyVariableName string
LegacyVariable string
}

func parameterDataSource() *schema.Resource {
Expand All@@ -72,7 +73,8 @@ func parameterDataSource() *schema.Resource {
Validation interface{}
Optional interface{}

LegacyVariable interface{}
LegacyVariableName interface{}
LegacyVariable interface{}
}{
Value: rd.Get("value"),
Name: rd.Get("name"),
Expand DownExpand Up@@ -101,7 +103,8 @@ func parameterDataSource() *schema.Resource {
rd.Set("optional", val)
return val
}(),
LegacyVariable: rd.Get("legacy_variable"),
LegacyVariableName: rd.Get("legacy_variable_name"),
LegacyVariable: rd.Get("legacy_variable"),
}, &parameter)
if err != nil {
return diag.Errorf("decode parameter: %s", err)
Expand DownExpand Up@@ -297,10 +300,17 @@ func parameterDataSource() *schema.Resource {
Computed: true,
Description: "Whether this value is optional.",
},
"legacy_variable_name": {
Type: schema.TypeString,
Optional: true,
RequiredWith: []string{"legacy_variable"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great that you added this requirement! 🤩

mtojek reacted with hooray emoji
Description: "Name of the legacy Terraform variable. Coder will use it to lookup the variable value.",
},
"legacy_variable": {
Type: schema.TypeString,
Optional: true,
Description: "The name of the Terraform variable used by legacy parameters. Coder will use it to lookup the parameter value.",
Type: schema.TypeString,
Optional: true,
RequiredWith: []string{"legacy_variable_name"},
Description: "Reference to the Terraform variable. Coder will use it to lookup the default value.",
},
},
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp