Skip to main content

OPA

FunctionDescriptionMeta
opa.runtime

output := opa.runtime()

Returns an object that describes the runtime environment where OPA is deployed.

Returns:
output (object[string: any])

includes a config key if OPA was started with a configuration file; an env key containing the environment variables that the OPA process was started with; includes version and commit keys containing the version and build commit of OPA.

SDK-dependent
danger

Policies that depend on the output of opa.runtime may return different answers depending on how OPA was started. If possible, prefer using an explicit input or data value instead of opa.runtime.

Debugging

Built-inDescriptionDetails
print(...)print is used to output the values of variables for debugging purposes. print calls have no effect on the result of queries or rules. All variables passed to print must be assigned inside of the query or rule. If any of the print arguments are undefined, their values are represented as <undefined> in the output stream. Because policies can be invoked via different interfaces (e.g., CLI, HTTP API, etc.) the exact output format differs. See the table below for details.SDK-dependent
APIOutputMemo
opa evalstderr
opa run (REPL)stderr
opa teststdoutSpecify -v to see output for passing tests. Output for failing tests is displayed automatically.
opa run -s (server)stderrSpecify --log-level=info (default) or higher. Output is sent to the log stream. Use --log-format=text for pretty output.
Go (library)io.Writerhttps://pkg.go.dev/github.com/open-policy-agent/opa/rego#example-Rego-Print_statements