- Notifications
You must be signed in to change notification settings - Fork923
fix(coderd): change the order of precedence between coder_workspace_tags and request tags#16119
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -355,10 +355,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) { | ||
wantTags: map[string]string{"owner": "", "scope": "organization", "foo": "bar", "a": "1", "b": "2"}, | ||
}, | ||
{ | ||
name: "main.tf withrequest tagsnot clobbering workspace tags", | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Is clobbering actually involved here? Since there's no two entries of the same tag the result is just a union. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. There's a test below that shows the actual clobbering behaviour. I guess "not clobbering" and "union" are similar enough in result but different enough in semantics to be confusing. But the tags are not a union, there is an order of precedence here that I'm trying to codify and demonstrate. | ||
files: map[string]string{ | ||
`main.tf`: ` | ||
// This file is, once again, the same as the above, except | ||
// for a slightly different comment. | ||
variable "a" { | ||
type = string | ||
default = "1" | ||
@@ -381,9 +382,57 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) { | ||
} | ||
}`, | ||
}, | ||
reqTags: map[string]string{"baz": "zap"}, | ||
wantTags: map[string]string{"owner": "", "scope": "organization", "foo": "bar", "baz": "zap", "a": "1", "b": "2"}, | ||
}, | ||
{ | ||
name: "main.tf with request tags clobbering workspace tags", | ||
files: map[string]string{ | ||
`main.tf`: ` | ||
// This file is the same as the above, except for this comment. | ||
variable "a" { | ||
type = string | ||
default = "1" | ||
} | ||
data "coder_parameter" "b" { | ||
type = string | ||
default = "2" | ||
} | ||
data "coder_parameter" "unrelated" { | ||
name = "unrelated" | ||
type = "list(string)" | ||
default = jsonencode(["a", "b"]) | ||
} | ||
resource "null_resource" "test" {} | ||
data "coder_workspace_tags" "tags" { | ||
tags = { | ||
"foo": "bar", | ||
"a": var.a, | ||
"b": data.coder_parameter.b.value, | ||
} | ||
}`, | ||
}, | ||
reqTags: map[string]string{"baz": "zap", "foo": "clobbered"}, | ||
wantTags: map[string]string{"owner": "", "scope": "organization", "foo": "clobbered", "baz": "zap", "a": "1", "b": "2"}, | ||
}, | ||
// FIXME(cian): we should skip evaluating tags for which values have already been provided. | ||
{ | ||
name: "main.tf with variable missing default value but value is passed in request", | ||
files: map[string]string{ | ||
`main.tf`: ` | ||
variable "a" { | ||
type = string | ||
} | ||
data "coder_workspace_tags" "tags" { | ||
tags = { | ||
"a": var.a, | ||
} | ||
}`, | ||
}, | ||
reqTags: map[string]string{"a": "b"}, | ||
// wantTags: map[string]string{"owner": "", "scope": "organization", "a": "b"}, | ||
expectError: `provisioner tag "a" evaluated to an empty value`, | ||
}, | ||
{ | ||
name: "main.tf with disallowed workspace tag value", | ||
files: map[string]string{ | ||
Uh oh!
There was an error while loading.Please reload this page.