-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Description
When a template-string (string interpolation) is part of a Partial Eval result query/support-module, it will be in its compiled form, where the template-string has been transformed from its "pretty", uncompiled form ($"{x}") into a call to internal.template_string() and, optionally, a set of set comprehensions for recording template-expression values. E.g.
package example
p := $"foo {input.bar} {input.baz}"$ echo '{"baz": 42}' | opa eval -I -p -u input.bar -fpretty -d policy.rego data.example.p
┌─────────┬────────────────────────────────────────────────────────────┐
│ Query 1 │ __local3__1 = {__local0__1 | __local0__1 = input.bar} │
│ │ internal.template_string(["foo ", __local3__1, " ", {42}]) │
└─────────┴────────────────────────────────────────────────────────────┘When a call to internal.template_string() is encountered in a PE result query/support-module, it should be possible to back-trace all generated set-comprehension assignment expression and reconstruct the "pretty" template-string, e.g.
┌─────────┬────────────────────────────────────────────────────────────┐
│ Query 1 │ $"foo {input.bar} {42}" │
└─────────┴────────────────────────────────────────────────────────────┘