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: support workspace tags#223

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 10 commits intomainfrom13218-workspace-tags
May 16, 2024
Merged

feat: support workspace tags#223

mtojek merged 10 commits intomainfrom13218-workspace-tags
May 16, 2024

Conversation

mtojek
Copy link
Member

@mtojekmtojek commentedMay 10, 2024
edited
Loading

Related:coder/coder#13218

This PR adds Terraform definition forcoder_workspace_tags with resource reference tests.

@mtojekmtojek self-assigned thisMay 10, 2024
return &schema.Resource{
Description: "Use this data source to configure workspace tags to select provisioners.",
ReadContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
rd.SetId(uuid.NewString())
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

For reviewers:

Originally I wanted to place here the logic to load HCL files and read raw content ofvalue properties. Unfortunately, I hit an interface blocker. Here is the story:

  1. PassCODER_TF_WORK_DIR from provisioner with disk path to the template.
  2. Useterraform-config-inspect to load module and get references (filename + pos) to data resources.
  3. Read raw attributes of the relevant data resource.

BUT...

schema.ResourceData is not aware of its own identity. It knows only its child properties, raw config and state diff. I'm afraid this is a blocker we can't find a workaround for, and we have to implement this logic in coderd.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why we want or need to do this here. This gets called atbuild time to allow other terraform resources to read data. I think we can just return the actual tagvalues and call it a day.

The loading of the files and parsing HCL should happen during the template version import, where we already have access to the raw files:https://github.com/coder/coder/blob/f14927955d7361d9a50c633e69fbebca2d9946cb/provisioner/terraform/parse.go#L26

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I don't understand why we want or need to do this here.

I didn't want to leak HCL parsing from the provider, but as long as we're doing it in template version import, I will extend that part.

@mtojekmtojek marked this pull request as ready for reviewMay 15, 2024 10:50
}

data "coder_workspace_tags" "custom_workspace_tags" {
tag {
Copy link
Contributor

Choose a reason for hiding this comment

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

tags are a mapstring -> string, so why is the syntax a list of tuples? This allows you to specify the same name more than once which is an error.

Copy link
MemberAuthor

@mtojekmtojekMay 15, 2024
edited
Loading

Choose a reason for hiding this comment

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

Sure, I can switch this to map, but keep in mind that it won't prevent the issue you mentioned (the same name more than once), as multiplecoder_workspace_tags can exist, right?

EDIT:

switched to map

return &schema.Resource{
Description: "Use this data source to configure workspace tags to select provisioners.",
ReadContext: func(ctx context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
rd.SetId(uuid.NewString())
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why we want or need to do this here. This gets called atbuild time to allow other terraform resources to read data. I think we can just return the actual tagvalues and call it a day.

The loading of the files and parsing HCL should happen during the template version import, where we already have access to the raw files:https://github.com/coder/coder/blob/f14927955d7361d9a50c633e69fbebca2d9946cb/provisioner/terraform/parse.go#L26

@mtojekmtojek requested a review fromspikecurtisMay 15, 2024 15:30
@mtojekmtojek merged commit041e000 intomainMay 16, 2024
11 checks passed
@mtojekmtojek deleted the 13218-workspace-tags branchMay 16, 2024 15:29
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMay 16, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@mafredrimafredriAwaiting requested review from mafredri

@spikecurtisspikecurtisAwaiting requested review from spikecurtis

Assignees

@mtojekmtojek

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@mtojek@johnstcn@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp