Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: tags argument in workspace tags block is optional #157

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

Merged
merged 2 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions extract/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func optionalStringEnum[T ~string](block *terraform.Block, key string, def T, va
tyAttr := block.GetAttribute(key)
return "", &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: fmt.Sprintf("Invalid %q attribute", key),
Summary: fmt.Sprintf("Invalid %q attribute for block %s", key, block.Label()),
Detail: err.Error(),
Subject: &(tyAttr.HCLAttribute().Range),
//Context: &(block.HCLBlock().DefRange),
Expand All @@ -275,7 +275,7 @@ func requiredString(block *terraform.Block, key string) (string, *hcl.Diagnostic

diag := &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: fmt.Sprintf("Invalid %q attribute", key),
Summary: fmt.Sprintf("Invalid %q attribute for block %s", key, block.Label()),
Detail: fmt.Sprintf("Expected a string, got %q", typeName),
Subject: &(tyAttr.HCLAttribute().Range),
//Context: &(block.HCLBlock().DefRange),
Expand Down Expand Up @@ -393,7 +393,7 @@ func required(block *terraform.Block, keys ...string) hcl.Diagnostics {
r := block.HCLBlock().Body.MissingItemRange()
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: fmt.Sprintf("Missing required attribute %q", key),
Summary: fmt.Sprintf("Missing required attribute %q for block %q", key, block.Label()),
Detail: fmt.Sprintf("The %s attribute is required", key),
Subject: &r,
Extra: nil,
Expand Down
11 changes: 1 addition & 10 deletions workspacetags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,9 @@ func workspaceTags(modules terraform.Modules, files map[string]*hcl.File) (types
for _, mod := range modules {
blocks := mod.GetDatasByType("coder_workspace_tags")
for _, block := range blocks {
evCtx := block.Context().Inner()

tagsAttr := block.GetAttribute("tags")
if tagsAttr.IsNil() {
r := block.HCLBlock().Body.MissingItemRange()
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Missing required argument",
Detail: `"tags" attribute is required by coder_workspace_tags blocks`,
Subject: &r,
EvalContext: evCtx,
})
// Nil tags block is valid, just skip it.
continue
}

Expand Down
Loading