mirror of https://github.com/coder/coder.git
This reverts commit 82f7b0cef4
.
This commit is contained in:
parent
81ed112cd3
commit
06394a5b8c
|
@ -16,25 +16,21 @@ const (
|
|||
// own their own operations.
|
||||
// Otherwise, the "owner" tag is always empty.
|
||||
func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string {
|
||||
// We copy the tags here to avoid overwriting the provided map. This can
|
||||
// cause data races when using dbmem.
|
||||
cp := map[string]string{}
|
||||
for k, v := range tags {
|
||||
cp[k] = v
|
||||
if tags == nil {
|
||||
tags = map[string]string{}
|
||||
}
|
||||
|
||||
_, ok := cp[TagScope]
|
||||
_, ok := tags[TagScope]
|
||||
if !ok {
|
||||
cp[TagScope] = ScopeOrganization
|
||||
delete(cp, TagOwner)
|
||||
tags[TagScope] = ScopeOrganization
|
||||
delete(tags, TagOwner)
|
||||
}
|
||||
switch cp[TagScope] {
|
||||
switch tags[TagScope] {
|
||||
case ScopeUser:
|
||||
cp[TagOwner] = userID.String()
|
||||
tags[TagOwner] = userID.String()
|
||||
case ScopeOrganization:
|
||||
delete(cp, TagOwner)
|
||||
delete(tags, TagOwner)
|
||||
default:
|
||||
cp[TagScope] = ScopeOrganization
|
||||
tags[TagScope] = ScopeOrganization
|
||||
}
|
||||
return cp
|
||||
return tags
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue