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(provisioner/terraform/tfparse): implement WorkspaceTagDefaultsFromFile#15236

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
johnstcn merged 14 commits intomainfromcj/15087-extract-workspace-tags
Nov 14, 2024

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedOct 25, 2024
edited
Loading

Relates to#15087 and#15427

Adds functionality toprovisioner/terraform/tfparse to extract the default values for acoder_workspace_tags data source from a given file.

A subsequent PR will hook this into the template creation flow.

Update: I've since found that Trivy usesits own Terraform parser to perform static analysis.
This will allow us to support things like function calls in future.
For now, I'm keeping our existing approach but I would like to leverage this package in future.

@johnstcnjohnstcn self-assigned thisOct 25, 2024
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

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

I don't have familiarity with the terraform parse library. I'll need to spend some time playing with this to get a better review.

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelNov 2, 2024
@mtojekmtojek self-requested a reviewNovember 4, 2024 09:02
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelNov 5, 2024
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

I focused on high level of this solution.

What I like here:

  • we're trying to construct the build context first and use it as a source of truth forParseExpression
  • There is a potential of introducing a "super parser" that can natively guess (support) placeholder values for provisioner tags

Open questions:

  • how does it work whencoder_parameter does not have a default value? maybe I missed it in code
  • is there any risk of breaking the build context if a template author pushes another template version with renamed parameters or variables?
  • when exactly this solution does not work?

I'm happy to discuss this solution in 1-1. I think you're on the right path but we may need to patch some loopholes.

@johnstcn
Copy link
MemberAuthor

Thanks for all the comments! I'm going to take a pass now and address them.

@johnstcnjohnstcnforce-pushed thecj/15087-extract-workspace-tags branch from9214bd4 to3db3e6bCompareNovember 11, 2024 14:04
}

if _, ok := resContent.Attributes["default"]; !ok {
defaultsM[dataResource.Name] = ""
Copy link
Member

Choose a reason for hiding this comment

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

Should we specify if the default is"" or actually not present?

This would make a tag"" if no default is provided. Should we error instead? Is that a breaking change if we error?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

That's a good point. The whole reason for doing this is to make sure that we havesome default defined for theworkspace_tags data source. So it probably should be an error.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Upon closer inspection, this isonly for parsingcoder_parameters. It is legit to have an empty default value for acoder_parameter. We do not want to block this behaviour.
However, when using thatcoder_parameter as a transitive source for acoder_workspace_tags value, we want to ensure that that tag is set. This is checked inWorkspaceTagDefaults and has its own corresponding unit test.

mtojek and Emyrk reacted with thumbs up emoji
@johnstcnjohnstcn requested a review fromEmyrkNovember 14, 2024 11:35
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

I assume this to be in good shape to get merged and play with it 👍 Nice work!

johnstcn reacted with heart emoji
// parseHCLFiler is the actual interface of *hclparse.Parser we use
// to parse HCL. This is extracted to an interface so we can more
// easily swap this out for an alternative implementation later on.
type parseHCLFiler interface {
Copy link
Member

Choose a reason for hiding this comment

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

nit: funny name :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I know :D I'm just following the Go convention of<function name>er.

@johnstcnjohnstcn merged commitbebc38e intomainNov 14, 2024
26 checks passed
@johnstcnjohnstcn deleted the cj/15087-extract-workspace-tags branchNovember 14, 2024 12:24
johnstcn added a commit that referenced this pull requestNov 25, 2024
…#15578)Relates to#15087 and#15427- Extracts provisioner job tags from `coder_workspace_tags` on templateversion creation using `provisioner/terraform/tfparse` added in#15236- Drops a WARN log in coderd if no matching provisioners found.- Also drops a warning message in the CLI if no provisioners are found.- To support both CLI and UI warnings, added a`codersdk.MatchedProvisioners` struct to the `TemplateVersion` responsecontaining details of how many provisioners were around at the time ofthe insert.Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mtojekmtojekmtojek approved these changes

@f0sself0sselAwaiting requested review from f0ssel

@EmyrkEmyrkAwaiting requested review from Emyrk

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@johnstcn@Emyrk@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp