File tree 1 file changed +10
-14
lines changed
1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -16,25 +16,21 @@ const (
16
16
// own their own operations.
17
17
// Otherwise, the "owner" tag is always empty.
18
18
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 {}
24
21
}
25
-
26
- _ , ok := cp [TagScope ]
22
+ _ , ok := tags [TagScope ]
27
23
if ! ok {
28
- cp [TagScope ] = ScopeOrganization
29
- delete (cp , TagOwner )
24
+ tags [TagScope ] = ScopeOrganization
25
+ delete (tags , TagOwner )
30
26
}
31
- switch cp [TagScope ] {
27
+ switch tags [TagScope ] {
32
28
case ScopeUser :
33
- cp [TagOwner ] = userID .String ()
29
+ tags [TagOwner ] = userID .String ()
34
30
case ScopeOrganization :
35
- delete (cp , TagOwner )
31
+ delete (tags , TagOwner )
36
32
default :
37
- cp [TagScope ] = ScopeOrganization
33
+ tags [TagScope ] = ScopeOrganization
38
34
}
39
- return cp
35
+ return tags
40
36
}
You can’t perform that action at this time.
0 commit comments