Skip to content

feat: store coder_workspace_tags in the database - #13294

Merged
mtojek merged 27 commits into
mainfrom
13218-workspace-tags
May 20, 2024
Merged

mtojek merged 27 commits into
mainfrom
13218-workspace-tags

Conversation

@mtojek

@mtojek mtojek commented May 16, 2024 •

Copy link
Copy Markdown
Member

Fixes: #13218
Follow-up: #13219

Note: I know this PR is relatively large, but there are chunks of generated code.

Changes:

  • add database table template_version_workspace_tags to store tags extracted from the template in the database (will be used in the follow up PR)
  • add logic to insert/query workspace tags from the database
  • update dependency on terraform-provider-coder
  • terraform runner can parse and extract workspace tags from a template

Terraform preview:

[API] 2024-05-17 10:56:18.081 [info]  terraform: unpacking template source archive  session_id=5c2d05eb-8b1b-476b-9f4b-7c8bf804a2fa  size_bytes=44544
[API] 2024-05-17 10:56:18.087 [info]  terraform: workspace tag found  key=cluster  value="\"developers\""
[API] 2024-05-17 10:56:18.087 [info]  terraform: workspace tag found  key=os  value=data.coder_parameter.os_selector.value
[API] 2024-05-17 10:56:18.087 [info]  terraform: workspace tag found  key=debug  value="\"${data.coder_parameter.feature_debug_enabled.value}+12345\""
[API] 2024-05-17 10:56:18.087 [info]  terraform: workspace tag found  key=cache  value="data.coder_parameter.feature_cache_enabled.value == \"true\" ? \"nix-with-cache\" : \"no-cache\""

Database preview:

select * from template_version_workspace_tags;
         template_version_id          |   key   |                                           value
--------------------------------------+---------+--------------------------------------------------------------------------------------------
 c7da54e8-37a3-4374-b103-bb76f9bd189b | cluster | "developers"
 c7da54e8-37a3-4374-b103-bb76f9bd189b | os      | data.coder_parameter.os_selector.value
 c7da54e8-37a3-4374-b103-bb76f9bd189b | debug   | "${data.coder_parameter.feature_debug_enabled.value}+12345"
 c7da54e8-37a3-4374-b103-bb76f9bd189b | cache   | data.coder_parameter.feature_cache_enabled.value == "true" ? "nix-with-cache" : "no-cache"
(4 rows)

@mtojek mtojek self-assigned this May 16, 2024
@mtojek
mtojek force-pushed the 13218-workspace-tags branch from 8556888 to 849ad82 Compare May 17, 2024 10:06
@mtojek
mtojek requested review from johnstcn and mafredri May 17, 2024 12:24
@mtojek
mtojek marked this pull request as ready for review May 17, 2024 12:24
Comment thread coderd/database/dbauthz/dbauthz.go Resolved
Comment thread provisionerd/runner/runner.go Resolved
Comment thread provisioner/terraform/parse.go Resolved
Comment thread coderd/database/unique_constraint.go Resolved
@mtojek
mtojek enabled auto-merge (squash) May 20, 2024 13:30
@mtojek
mtojek merged commit b8b80fe into main May 20, 2024
@mtojek
mtojek deleted the 13218-workspace-tags branch May 20, 2024 13:30
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2024
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.

coderd: implement coder_workspace_tags

2 participants