Conversation
|
@ma-ts the command you issued was incorrect. Please try again. Examples are: and |
|
@ma-ts Thanks for the contribution. Do also add I happened to see that you have also created feature request in the Azure Policy repo. We are working on some interesting projects involving Azure Policy and Regorus. Hence, I'm curious whether you are already using Regorus. |
|
Hi @anakrish, I will do that! And yes, all of this is part of a big policy overhaul in our organisation, and actually we are already using it in some services. I am soon going to be open sourcing a project as well to provide a Rust-based ingress controller that uses Regorus and integrates natively with OIDC, and has special support for Entra ID |
anakrish
left a comment
There was a problem hiding this comment.
https://docs.rs/serde_json/latest/serde_json/fn.from_value.html and https://docs.rs/serde_json/latest/serde_json/fn.to_value.html can be used to avoid explicit serialization to strings.
| ensure_args_count(span, name, params, args, 2)?; | ||
|
|
||
| let object_str = args[0].to_json_str()?; | ||
| let mut object: serde_json::Value = serde_json::from_str(&object_str) |
There was a problem hiding this comment.
| let mut object: serde_json::Value = serde_json::from_str(&object_str) | |
| let mut object: serde_json::Value = serde_json::to_value(&args[0]) |
| ensure_array(name, ¶ms[1], args[1].clone())?; | ||
|
|
||
| let patches_str = args[1].to_json_str()?; | ||
| let patches_json: serde_json::Value = serde_json::from_str(&patches_str) |
There was a problem hiding this comment.
| let patches_json: serde_json::Value = serde_json::from_str(&patches_str) | |
| let patches_json: serde_json::Value = serde_json::to_value(&args[1]) |
|
|
||
| match json_patch::patch(&mut object, &patch) { | ||
| Ok(_) => { | ||
| let result_str = serde_json::to_string(&object) |
There was a problem hiding this comment.
| let result_str = serde_json::to_string(&object) | |
| let value : regorus::Value = serde_json::from_value&object) |
|
Hey @ma-ts, just a gentle ping on this. |
Add json.patch builtin support
Fixes: #95
Implements the
json.patchbuiltin function according to the OPA specification, enabling RFC6902 JSON Patch operations on objects.Changes
json-patchcrate v4.0.0 with optionaljsonpatchfeaturejson.patch(object, patches)function that applies JSON Patch operations atomicallyFeatures
Usage