Skip to content

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 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 4 commits into from
Mar 10, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Mar 10, 2023

Related: coder/coder#6368

This PR adds new property to coder_parameter - legacy_variable_name.

It's outcome of the research here.

@mtojek mtojek self-assigned this Mar 10, 2023
@mtojek mtojek requested a review from mafredri March 10, 2023 10:27
@mtojek mtojek marked this pull request as ready for review March 10, 2023 10:27
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

The descriptions could be slightly clarified, but other than that I think this looks good! 👍🏻

@@ -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 legacy parameter. Coder will use it to lookup the default value.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could call this legacy_variable_{,default_}value to clearly indicate the difference between name/default value?

PS. It might be a bit confusing to users to call these variable when the description mentions parameters. Perhaps reword the description to only mention variables and not parameters? (Same below.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I rephrased the sentence to refer only to variables.

Maybe we could call this legacy_variable_{,default_}value to clearly indicate the difference between name/default value?

I'm hesitant as I'd rather see template authors referring to variables. I have a feeling that legacy_variable_{,default_}value may suggest inputting a number instead of ${var.foobar}. Actually, it's unfortunate that we need a field for a variable name, but Terraform can't operate on metadata (resource name).

Besides that, this is only for migration purposes. Those legacy_* should be present only for one update cycle of a template. I think we're good...

Copy link
Member

Choose a reason for hiding this comment

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

I agree with your reasoning for keeping the name as-is. 👍🏻

"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 mtojek merged commit 9bcdcd6 into coder:main Mar 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants