mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
ast, compile: Update opa build --debug output
This commit tweaks the --debug output format to be slightly more readable. The comprehension indexing messages now have a prefix to make them more discernable and the optimizer output is now aggregated so that it's more concise and clear what parameters are being passed to partial evaluation. Signed-off-by: Torin Sandall <torinsandall@gmail.com>
This commit is contained in:
+12
-2
@@ -629,10 +629,12 @@ func (o *optimizer) Do(ctx context.Context) error {
|
||||
unknowns = o.findUnknowns()
|
||||
}
|
||||
|
||||
required := o.findRequiredDocuments(e)
|
||||
|
||||
r := rego.New(
|
||||
rego.ParsedQuery(ast.NewBody(ast.Equality.Expr(resultsym, e))),
|
||||
rego.PartialNamespace(o.nsprefix),
|
||||
rego.DisableInlining(o.findRequiredDocuments(e)),
|
||||
rego.DisableInlining(required),
|
||||
rego.ShallowInlining(o.shallow),
|
||||
rego.SkipPartialNamespace(true),
|
||||
rego.ParsedUnknowns(unknowns),
|
||||
@@ -640,6 +642,15 @@ func (o *optimizer) Do(ctx context.Context) error {
|
||||
rego.Store(store),
|
||||
)
|
||||
|
||||
o.debug.Printf("optimizer: entrypoint: %v", e)
|
||||
o.debug.Printf(" partial-namespace: %v", o.nsprefix)
|
||||
o.debug.Printf(" disable-inlining: %v", required)
|
||||
o.debug.Printf(" shallow-inlining: %v", o.shallow)
|
||||
|
||||
for i := range unknowns {
|
||||
o.debug.Printf(" unknown: %v", unknowns[i])
|
||||
}
|
||||
|
||||
pq, err := r.Partial(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -738,7 +749,6 @@ func (o *optimizer) findUnknowns() []*ast.Term {
|
||||
return true
|
||||
}
|
||||
if !refs.ContainsPrefix(prefix) {
|
||||
o.debug.Printf("%s: marking %v as unknown", x[0].Location, prefix)
|
||||
unknowns.AddPrefix(prefix)
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user