diff --git a/pkg/contexts/contexts.go b/pkg/contexts/contexts.go index 1e6928f82..b414a92e9 100644 --- a/pkg/contexts/contexts.go +++ b/pkg/contexts/contexts.go @@ -38,8 +38,16 @@ type CRE struct { // Normalized returns a possibly modified CRE with normalized values. func (c CRE) Normalized() CRE { + c.Org = strings.TrimPrefix(c.Org, "org_") + c.Org = strings.TrimPrefix(c.Org, "0x") + c.Org = strings.ToLower(c.Org) + + c.Owner = strings.TrimPrefix(c.Owner, "owner_") c.Owner = strings.TrimPrefix(c.Owner, "0x") c.Owner = strings.ToLower(c.Owner) + + c.Workflow = strings.TrimPrefix(c.Workflow, "0x") + c.Workflow = strings.ToLower(c.Workflow) return c } diff --git a/pkg/settings/keys_test.go b/pkg/settings/keys_test.go index d9a5775e9..430293689 100644 --- a/pkg/settings/keys_test.go +++ b/pkg/settings/keys_test.go @@ -10,9 +10,9 @@ import ( func TestTenant_rawKeys(t *testing.T) { const ( - org = "AcmeCorporation" + org = "acmecorporation" owner = "1234abcd" - workflow = "ABCDEFGH" + workflow = "abcdefgh" key = "foo" ) for _, test := range []struct { diff --git a/pkg/settings/limits/resource_test.go b/pkg/settings/limits/resource_test.go index 4c943062f..b587c6a98 100644 --- a/pkg/settings/limits/resource_test.go +++ b/pkg/settings/limits/resource_test.go @@ -72,7 +72,7 @@ func ExampleResourceLimiter_Use() { func ExampleMultiResourcePoolLimiter() { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - ctx = contexts.WithCRE(ctx, contexts.CRE{Org: "orgID", Owner: "owner-id", Workflow: "workflowID"}) + ctx = contexts.WithCRE(ctx, contexts.CRE{Org: "org-id", Owner: "owner-id", Workflow: "workflow-id"}) global := GlobalResourcePoolLimiter[int](100) freeGlobal, err := global.Wait(ctx, 95) if err != nil { @@ -118,9 +118,9 @@ func ExampleMultiResourcePoolLimiter() { free() // Output: // resource limited: cannot use 10, already using 95/100 - // resource limited for org[orgID]: cannot use 10, already using 45/50 + // resource limited for org[org-id]: cannot use 10, already using 45/50 // resource limited for owner[owner-id]: cannot use 10, already using 15/20 - // resource limited for workflow[workflowID]: cannot use 10, already using 5/10 + // resource limited for workflow[workflow-id]: cannot use 10, already using 5/10 // }