Is there a way to compile the rego file used by OPA into WASM using Java?
Currently I'm using the following command to compile a rego policy into WASM and bundling it with data into a gz file
./opa build -t wasm -o ../out/bundle.tar.gz -e example/allowed policy.rego data.json
I'm using kawamuray library to evaluate the policies contained in wasm file.
// This is the relevant code..
// I want to pass the rego policy file name in place of gzBundleName
// then compile it into wasm and carry on the rest of program as such
public static void executePolicy(String gzBundleName, String user) {
try {
ObjectMapper objectMapper = new ObjectMapper();
Bundle bundle = BundleUtil.extractBundle(gzBundleName);
try (OPAModule om = new OPAModule(bundle)) {
String valueString = om.evaluate(user, entry_point);
JsonNode _evaluation = objectMapper.readTree(valueString);
logger.info("evaluation result :"+ _evaluation.get(0).get("result"));
}
} catch (IOException e) {
logger.warn("failure", e);
}
}