Skip to content

Commit 06394a5

Browse files
authored
Revert "fix: prevent data race when mutating tags (#11200)" (#11216)
This reverts commit 82f7b0c.
1 parent 81ed112 commit 06394a5

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

provisionersdk/provisionertags.go

+10-14
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,21 @@ const (
1616
// own their own operations.
1717
// Otherwise, the "owner" tag is always empty.
1818
func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string {
19-
// We copy the tags here to avoid overwriting the provided map. This can
20-
// cause data races when using dbmem.
21-
cp := map[string]string{}
22-
for k, v := range tags {
23-
cp[k] = v
19+
if tags == nil {
20+
tags = map[string]string{}
2421
}
25-
26-
_, ok := cp[TagScope]
22+
_, ok := tags[TagScope]
2723
if !ok {
28-
cp[TagScope] = ScopeOrganization
29-
delete(cp, TagOwner)
24+
tags[TagScope] = ScopeOrganization
25+
delete(tags, TagOwner)
3026
}
31-
switch cp[TagScope] {
27+
switch tags[TagScope] {
3228
case ScopeUser:
33-
cp[TagOwner] = userID.String()
29+
tags[TagOwner] = userID.String()
3430
case ScopeOrganization:
35-
delete(cp, TagOwner)
31+
delete(tags, TagOwner)
3632
default:
37-
cp[TagScope] = ScopeOrganization
33+
tags[TagScope] = ScopeOrganization
3834
}
39-
return cp
35+
return tags
4036
}

0 commit comments

Comments
 (0)