chore: Compile rego once to save CPU cycles in testing (#4169)

Compiling rego isn't very fast, so this should speed up tests in CI!
This commit is contained in:
Kyle Carberry
2022-09-23 11:26:04 -05:00
committed by GitHub
parent 1e1967e0db
commit 8738755ffc
4 changed files with 33 additions and 41 deletions

View File

@ -109,13 +109,7 @@ func New(options *Options) *API {
options.MetricsCacheRefreshInterval = time.Hour
}
if options.Authorizer == nil {
var err error
options.Authorizer, err = rbac.NewAuthorizer()
if err != nil {
// This should never happen, as the unit tests would fail if the
// default built in authorizer failed.
panic(xerrors.Errorf("rego authorize panic: %w", err))
}
options.Authorizer = rbac.NewAuthorizer()
}
if options.PrometheusRegistry == nil {
options.PrometheusRegistry = prometheus.NewRegistry()