Skip to content

feat: import value from legacy variable #109

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 7, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Mar 7, 2023

Related: coder/coder#6368

This PR introduces a new coder_parameter property, legacy_variable. The idea is to link it with the old parameter. See:

provider "coder" {}

variable "old_account_name" {
  type    = string
  default = "fake-user" # for testing purposes, no need to set via env TF_...
}

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

coder_parameter.default will be equal to the value of var.old_account_name, in this case fake-user.

Notice: once admin enables feature_use_managed_variables = true, users won't be able to the legacy_variable property. This is only for transition purposes. (old -> new params).

Comment:

I'm curious if it isn't good enough to directly link default with var.old_account_name:

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

^ @bpmct That would be a good experiment :)

@mtojek mtojek requested review from kylecarbs and bpmct March 7, 2023 13:48
@mtojek mtojek self-assigned this Mar 7, 2023
@mtojek mtojek marked this pull request as ready for review March 7, 2023 14:01
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

If we persist with the var.xxx syntax, I suppose migration would actually be seamless, because the prior value would be used 🤔... that's a big 🧠 idea!

@mtojek mtojek merged commit 7c0f341 into coder:main Mar 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 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.

3 participants