mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: Minor rbac memory optimization (#7391)
* test: Add benchmark for static rbac roles * static roles should only be allocated once * A unit test that modifies the ast value should not mess with the globals * Cache subject AST values to avoid reallocating slices
This commit is contained in:
@@ -144,7 +144,8 @@ var (
|
||||
},
|
||||
}),
|
||||
Scope: rbac.ScopeAll,
|
||||
}
|
||||
}.WithCachedASTValue()
|
||||
|
||||
subjectAutostart = rbac.Subject{
|
||||
ID: uuid.Nil.String(),
|
||||
Roles: rbac.Roles([]rbac.Role{
|
||||
@@ -161,7 +162,8 @@ var (
|
||||
},
|
||||
}),
|
||||
Scope: rbac.ScopeAll,
|
||||
}
|
||||
}.WithCachedASTValue()
|
||||
|
||||
subjectSystemRestricted = rbac.Subject{
|
||||
ID: uuid.Nil.String(),
|
||||
Roles: rbac.Roles([]rbac.Role{
|
||||
@@ -188,7 +190,7 @@ var (
|
||||
},
|
||||
}),
|
||||
Scope: rbac.ScopeAll,
|
||||
}
|
||||
}.WithCachedASTValue()
|
||||
)
|
||||
|
||||
// AsProvisionerd returns a context with an actor that has permissions required
|
||||
|
||||
Reference in New Issue
Block a user