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: use preview to compute workspace tags from terraform#18720

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
Emyrk merged 1 commit intomainfromstevenmasley/preview_tags_rebase
Jul 3, 2025

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedJul 2, 2025
edited
Loading

What this does

If using dynamic parameters, workspace tags are extracted usingcoder/preview. This occurs at template version import and workspace create.

Templates that are not opted into dynamic parameters will usetfparse.

Future Work

Whenpreview is used as the source of truth for tags, we can removetfparse.

Closescoder/internal#698

johnstcn reacted with heart emoji
@EmyrkGraphite App
Copy link
MemberAuthor

Emyrk commentedJul 2, 2025
edited
Loading

@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch 2 times, most recently from6c1fdf5 to20d0254CompareJuly 2, 2025 16:10
@EmyrkEmyrkforce-pushed thestevenmasley/preview_errors branch from15a6ca1 tof0dd768CompareJuly 2, 2025 16:10
@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch 2 times, most recently from6f3d388 tof4cd152CompareJuly 2, 2025 16:46
@EmyrkEmyrkforce-pushed thestevenmasley/preview_errors branch fromf0dd768 toa87678dCompareJuly 2, 2025 16:48
@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch 2 times, most recently from29a7cf6 to4d06a6cCompareJuly 2, 2025 17:32
"github.com/coder/coder/v2/testutil"
)

funcTest_DynamicWorkspaceTagDefaultsFromFile(t*testing.T) {
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This test is copied fromtfparse_test.go.

The tfparse test can be removed when this becomes the new standard.

johnstcn reacted with thumbs up emoji
@EmyrkEmyrkforce-pushed thestevenmasley/preview_errors branch from96c83c7 to8d594a7CompareJuly 2, 2025 21:51
@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch 5 times, most recently fromfc1ad45 to11e0407CompareJuly 3, 2025 12:25
@EmyrkEmyrk changed the base branch fromstevenmasley/preview_errors tographite-base/18720July 3, 2025 13:33
@EmyrkEmyrkforce-pushed thegraphite-base/18720 branch from3cc9349 to699dd8eCompareJuly 3, 2025 13:34
@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch from11e0407 tod1ed169CompareJuly 3, 2025 13:34
@graphite-appgraphite-appbot changed the base branch fromgraphite-base/18720 tomainJuly 3, 2025 13:35
@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch 4 times, most recently from35d29b9 toea564d1CompareJuly 3, 2025 13:59
@EmyrkEmyrk requested a review fromCopilotJuly 3, 2025 14:02
return
}

vardynamicTemplatebool
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Unfortunate, but orphan'd template versions can never use dynamic parameters 😢

Copy link
Member

Choose a reason for hiding this comment

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

By 'orphaned' you mean !(active version)?

I wonder how this squares with the UI option you get to create a workspace from this template version when you create a new template version.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

No, I mean when you first create a new template, the flow is:

  • Create template version
  • Create template using template version

So in step 1, the template version is orphaned. And it can remain that way.

johnstcn reacted with thumbs up emoji
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the tfparse-based workspace tag extraction with thepreview SDK for dynamic-parameter templates, adds caching in the workspace builder, and expands end-to-end and unit tests for tag parsing.

  • Upgrade togithub.com/coder/preview v1.0.3 for tag extraction
  • ImplementdynamicTemplateVersionTags/classicTemplateVersionTags in the API and cache tags in the workspace builder
  • Addtags_internal_test.go and integration testTestDynamicWorkspaceTags, plus a zip‐FS helper

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
go.modBumpgithub.com/coder/preview to v1.0.3-…
enterprise/coderd/testdata/.../main.tfAdd Terraform test case for workspace tags
enterprise/coderd/dynamicparameters_test.goAddTestDynamicWorkspaceTags integration test
coderd/wsbuilder/wsbuilder.goCache and return dynamic workspace tags
coderd/templateversions.goRoute tag parsing throughpreview.Preview for dynamic templates
coderd/dynamicparameters/tags.goAddCheckTags and diagnostics for invalid tag values
coderd/dynamicparameters/error.goRename error constructors and update error messaging
coderd/dynamicparameters/render.goRefactor workspace owner resolution and add version support
coderd/dynamicparameters/resolver.goRename error calls to lowercase versions
coderd/coderdtest/dynamicparameters.goExposeVersion hook in test helper
archive/fs/zip.goIntroduceFromZipReader helper for zip archives
Comments suppressed due to low confidence (4)

coderd/templateversions.go:1765

  • [nitpick] This new helper method lacks a GoDoc comment; consider adding a brief comment explaining its behavior and parameters.
func (api *API) dynamicTemplateVersionTags(ctx context.Context, rw http.ResponseWriter, orgID uuid.UUID, owner uuid.UUID, file database.File) (map[string]string, bool) {

coderd/templateversions.go:1795

  • The unsupported mimetype branch indynamicTemplateVersionTags isn’t exercised by existing tests; consider adding a test to cover this error path.
default:

archive/fs/zip.go:1

  • The newFromZipReader helper lacks unit tests; consider adding tests to validate correct in-memory FS creation from zip data.
package archivefs

coderd/dynamicparameters/error.go:21

  • [nitpick] The error message is now "Failed to parse provisioner tags", which may be confusing in a workspace-tag context; consider using "workspace tags" for consistency with other messages.
func tagValidationError(diags hcl.Diagnostics) *DiagnosticError {

@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch fromea564d1 to76ca1faCompareJuly 3, 2025 14:08
@EmyrkEmyrk marked this pull request as ready for reviewJuly 3, 2025 14:08
@EmyrkEmyrk requested a review fromjohnstcnJuly 3, 2025 14:30
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

🐐

},
expectTags:map[string]string{"cluster":"developers","platform":"kubernetes","region":"us"},
expectedFailedTags:map[string]string{
"az":"Tag value is not known, it likely refers to a variable that is not set or has no default.",
Copy link
Member

Choose a reason for hiding this comment

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

review: this also differs slightly from tfparse which returns an empty value, but the empty result is checked externally IIRC

Emyrk reacted with thumbs up emoji
Comment on lines +387 to +389
expectedFailedTags:map[string]string{
"hostname":unknownTag,
},
Copy link
Member

Choose a reason for hiding this comment

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

review: same result as tfparse, but the error is nicer here 👍

Emyrk reacted with thumbs up emoji
"az":"a",
},
expectedFailedTags:map[string]string{
"some_path":unknownTag,
Copy link
Member

Choose a reason for hiding this comment

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

review: it might be better to have an explicit "function not allowed" error here

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

You can actually use the function, but it's the~ in the function call. The~ cannot be expanded inpreview, so that invocation of the function fails. I'll make a comment

Comment on lines +570 to +584
expectTags:map[string]string{
"stringvar":"a",
"numvar":"1",
"boolvar":"true",
"stringparam":"a",
"numparam":"1",
"boolparam":"true",
"listparam":`["a", "b"]`,// OK because params are cast to strings
},
expectedFailedTags:map[string]string{
"listvar":invalidValueType,
"mapvar":invalidValueType,
},
Copy link
Member

Choose a reason for hiding this comment

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

review: behavioural difference from tfparse, but this was discussed and agreed to be correct as the provider will complain about the type not being stringy enough

Emyrk reacted with thumbs up emoji
@EmyrkEmyrkforce-pushed thestevenmasley/preview_tags_rebase branch from76ca1fa toff0cf69CompareJuly 3, 2025 17:20
@EmyrkEmyrk merged commita099a8a intomainJul 3, 2025
30 checks passed
@EmyrkEmyrk deleted the stevenmasley/preview_tags_rebase branchJuly 3, 2025 19:35
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 3, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

Copilot code reviewCopilotCopilot left review comments

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

chore: use preview engine to evaluate coder_workspace_tags
2 participants
@Emyrk@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp