Skip to content
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

Improve version compatibility #224

Closed
Tracked by #217
ammario opened this issue May 10, 2024 · 3 comments · Fixed by #246
Closed
Tracked by #217

Improve version compatibility #224

ammario opened this issue May 10, 2024 · 3 comments · Fixed by #246
Assignees
Labels
docs Improvements or additions to documentation

Comments

@ammario
Copy link
Member

ammario commented May 10, 2024

In coder/coder#13122 a user sees empty values when referencing ${data.coder_workspace.me.template_id} in their template. This happens because their coder server version is behind the provider, and this kind of issue will continue to appear as we implement more provider functionality (#220, #219).

There are two things we should do to fix this:

  1. In our docs under each attribute and resource, declare the Coder version requirements

  2. Replace code like:

    templateID := os.Getenv("CODER_WORKSPACE_TEMPLATE_ID")
    _ = rd.Set("template_id", templateID)
    templateName := os.Getenv("CODER_WORKSPACE_TEMPLATE_NAME")
    _ = rd.Set("template_name", templateName)
    templateVersion := os.Getenv("CODER_WORKSPACE_TEMPLATE_VERSION")
    _ = rd.Set("template_version", templateVersion)

with LookupEnv and fail the build when a value is missing instead of using blanks.

@coder-labeler coder-labeler bot added docs Improvements or additions to documentation enhancement labels May 10, 2024
@johnstcn
Copy link
Member

As an extra check, we could pass in the Coder version to the provisioner, and then check the version against the oldest version of Coder supported by the provisioner. WDYT?

@ammario
Copy link
Member Author

ammario commented May 26, 2024

As an extra check, we could pass in the Coder version to the provisioner, and then check the version against the oldest version of Coder supported by the provisioner. WDYT?

I think passing the version is a good idea, but I think we should add rules to convert old parameters into new ones instead of "breaking" at certain version boundaries.

We want to minimize upgrade anxiety caused by breakage.

@mtojek
Copy link
Member

mtojek commented Jun 26, 2024

SchemaVersion has been merged.

Next steps:

Coder provisioner uses terraform-plugin-coder in different contexts - a dry run, a template run, a workspace build, etc. We can't use helpers.RequireEnv() in other modes than "workspace build", as the provisioner does not set these values (empty variable). If we switch to helpers.RequireEnv() now, "template import" will fail due to unset env values.
We can implement a workaround by passing the extra env variable CODER_WORKSPACE_BUILD_ID=.... If this variable is set, the plugin should presence the required env values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants