fix: duplicate tags map in mutation to resolve race (#14047)

* fix: duplicate tags map in mutation to resolve race

See: https://github.com/coder/coder/actions/runs/10149619748/job/28064952716?pr=14046

* Fix deployment values race
This commit is contained in:
Kyle Carberry
2024-07-30 03:37:13 -04:00
committed by GitHub
parent 3209c863b8
commit 893169c83b
2 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -34,11 +34,11 @@ func TestEnterpriseCreate(t *testing.T) {
secondTemplates []string
}
dv := coderdtest.DeploymentValues(t)
dv.Experiments = []string{string(codersdk.ExperimentMultiOrganization)}
// setupMultipleOrganizations creates an extra organization, assigns a member
// both organizations, and optionally creates templates in each organization.
setupMultipleOrganizations := func(t *testing.T, args setupArgs) setupData {
dv := coderdtest.DeploymentValues(t)
dv.Experiments = []string{string(codersdk.ExperimentMultiOrganization)}
ownerClient, first := coderdenttest.New(t, &coderdenttest.Options{
Options: &coderdtest.Options{
DeploymentValues: dv,
+4 -3
View File
@@ -18,9 +18,10 @@ const (
// NOTE: "owner" must NEVER be nil. Otherwise it will end up being
// duplicated in the database, as idx_provisioner_daemons_name_owner_key
// is a partial unique index that includes a JSON field.
func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string {
if tags == nil {
tags = map[string]string{}
func MutateTags(userID uuid.UUID, provided map[string]string) map[string]string {
tags := map[string]string{}
for k, v := range provided {
tags[k] = v
}
_, ok := tags[TagScope]
if !ok {