From 06394a5b8c71e05847cd373b028075234299f1b7 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Thu, 14 Dec 2023 12:37:55 -0600 Subject: [PATCH] Revert "fix: prevent data race when mutating tags (#11200)" (#11216) This reverts commit 82f7b0cef42a591755342a402232d5f2ac138816. --- provisionersdk/provisionertags.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/provisionersdk/provisionertags.go b/provisionersdk/provisionertags.go index 3071d0f535..970cf2094d 100644 --- a/provisionersdk/provisionertags.go +++ b/provisionersdk/provisionertags.go @@ -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 }