I followed the example of https://www.openpolicyagent.org/docs/latest/#5-try-opa-as-a-go-library. Important code snippets:
r := rego.New(
rego.Query("x = data.example.allow"),
rego.Load([]string{"./example.rego"}, nil)
...
rs, err := query.Eval(ctx, rego.EvalInput(input))
...
How can I add external data (data.json
) such that I can use, e.g., data.wantedName
in the rego policy to access it?
I tried to read through the go doc and the examples but I couldn't find any helpful information.
Thanks!