Skip to content

Commit 29a8f35

Browse files
committed
pkg/contexts: expand CRE.Normalized
1 parent 2df013c commit 29a8f35

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

pkg/contexts/contexts.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ type CRE struct {
3838

3939
// Normalized returns a possibly modified CRE with normalized values.
4040
func (c CRE) Normalized() CRE {
41+
c.Org = strings.TrimPrefix(c.Org, "org_")
42+
c.Org = strings.TrimPrefix(c.Org, "0x")
43+
c.Org = strings.ToLower(c.Org)
44+
45+
c.Owner = strings.TrimPrefix(c.Owner, "owner_")
4146
c.Owner = strings.TrimPrefix(c.Owner, "0x")
4247
c.Owner = strings.ToLower(c.Owner)
48+
49+
c.Workflow = strings.TrimPrefix(c.Workflow, "0x")
50+
c.Workflow = strings.ToLower(c.Workflow)
4351
return c
4452
}
4553

pkg/settings/keys_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010

1111
func TestTenant_rawKeys(t *testing.T) {
1212
const (
13-
org = "AcmeCorporation"
13+
org = "acmecorporation"
1414
owner = "1234abcd"
15-
workflow = "ABCDEFGH"
15+
workflow = "abcdefgh"
1616
key = "foo"
1717
)
1818
for _, test := range []struct {

pkg/settings/limits/resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func ExampleResourceLimiter_Use() {
7272
func ExampleMultiResourcePoolLimiter() {
7373
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
7474
defer cancel()
75-
ctx = contexts.WithCRE(ctx, contexts.CRE{Org: "orgID", Owner: "owner-id", Workflow: "workflowID"})
75+
ctx = contexts.WithCRE(ctx, contexts.CRE{Org: "org-id", Owner: "owner-id", Workflow: "workflow-id"})
7676
global := GlobalResourcePoolLimiter[int](100)
7777
freeGlobal, err := global.Wait(ctx, 95)
7878
if err != nil {

0 commit comments

Comments
 (0)