-
Is there any particular reason for the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The reason get_modules is hidden is that it exposes the AST which is unstable at this point in time. There are some changes being considered for the AST that will overall benefit Regorus, but might break someone that uses the AST. The API exists in engine (#50) so as to not break @eric-therond who uses the AST directly. The hidden API will likely be removed after a few releases, once that use case is also properly supported, without exposing the internals. @thedavemarshall also expressed interest in obtaining the list of loaded modules. Maybe a good way is to have Currently, one way to obtain the name of the packages would be to evaluate a query that requests the keys within the data document $ regorus eval -d policy.rego "data[package_name]"
...
"bindings": {
"package_name": "agent_policy"
}
... let mut engine = Engine::new();
engine.add_policy(...);
engine.set_strict_builtin_errors(false); // Ensure that the query below does not raise errors due to missing data/input.
// Do not add_data since the added data shows up as keys in the `data` document.
// Create bindings to package names.
let results = engine.eval_query("data[package_name]".to_string(), false)?;
// Name of first package.
let package_name = results.result[0].bindings["package_name"].as_string()?.to_string(); |
Beta Was this translation helpful? Give feedback.
The reason get_modules is hidden is that it exposes the AST which is unstable at this point in time. There are some changes being considered for the AST that will overall benefit Regorus, but might break someone that uses the AST.
The API exists in engine (#50) so as to not break @eric-therond who uses the AST directly. The hidden API will likely be removed after a few releases, once that use case is also properly supported, without exposing the internals.
@thedavemarshall also expressed interest in obtaining the list of loaded modules.
Maybe a good way is to have
add_policy
functions return the name of the package?Currently, one way to obtain the name of the packages would be to evaluat…