mirror of
https://github.com/coder/coder.git
synced 2025-07-21 01:28:49 +00:00
fix(provisioner/terraform/tfparse): allow empty values in coder_workspace_tag defaults (#16303)
* chore(docs): update docs re workspace tag default values * chore(coderdenttest): use random name instead of t.Name() in newExternalProvisionerDaemon * fix(provisioner/terraform/tfparse): allow empty values in coder_workspace_tag defaults
This commit is contained in:
@ -429,9 +429,8 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
|
||||
}
|
||||
}`,
|
||||
},
|
||||
reqTags: map[string]string{"a": "b"},
|
||||
// wantTags: map[string]string{"owner": "", "scope": "organization", "a": "b"},
|
||||
expectError: `provisioner tag "a" evaluated to an empty value`,
|
||||
reqTags: map[string]string{"a": "b"},
|
||||
wantTags: map[string]string{"owner": "", "scope": "organization", "a": "b"},
|
||||
},
|
||||
{
|
||||
name: "main.tf with disallowed workspace tag value",
|
||||
@ -568,6 +567,42 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
|
||||
},
|
||||
wantTags: map[string]string{"owner": "", "scope": "organization"},
|
||||
},
|
||||
{
|
||||
name: "main.tf with tags from parameter with default value from variable no default",
|
||||
files: map[string]string{
|
||||
`main.tf`: `
|
||||
variable "provisioner" {
|
||||
type = string
|
||||
}
|
||||
variable "default_provisioner" {
|
||||
type = string
|
||||
default = "" # intentionally blank, set on template creation
|
||||
}
|
||||
data "coder_parameter" "provisioner" {
|
||||
name = "provisioner"
|
||||
mutable = false
|
||||
default = var.default_provisioner
|
||||
dynamic "option" {
|
||||
for_each = toset(split(",", var.provisioner))
|
||||
content {
|
||||
name = option.value
|
||||
value = option.value
|
||||
}
|
||||
}
|
||||
}
|
||||
data "coder_workspace_tags" "tags" {
|
||||
tags = {
|
||||
"provisioner" : data.coder_parameter.provisioner.value
|
||||
}
|
||||
}`,
|
||||
},
|
||||
reqTags: map[string]string{
|
||||
"provisioner": "alpha",
|
||||
},
|
||||
wantTags: map[string]string{
|
||||
"provisioner": "alpha", "owner": "", "scope": "organization",
|
||||
},
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user