Experiment to mimic opa playground
Here are the tests I ran
opa eval --input input.json --data test.rego "data.hello"
results in{}
opa eval --input input.json --data test.rego "hello"
results inrego_unsafe_var_error
opa eval --input input.json --data test.rego "play.hello"
results inrego_unsafe_var_error
But if you
- Go to playground - https://play.openpolicyagent.org/p/ACpt6leoEx which has same input & rego files,
- Select word "hello" on line 21
- Click on "Evaluate Selection" in top right corner
- You will see valid text in output panel
opa eval --input input.json --data test.rego --package "play" "data.play.hello"
Basically this is how we can mimic playground using eval:
opa eval \
--input <path to input.json file> \
--data <path to data.json file> \
--data <path to rego file> \
--import <import 1 from rego file> \
--import <import n from rego file> \
--package <package from rego file> \
'<query>'