Load policy rules and data from strings (data is YAML). Preprocesses the YAML data to expand access presets and validate L7 config.
(policy: &str, data_yaml: &str)
| 160 | /// |
| 161 | /// Preprocesses the YAML data to expand access presets and validate L7 config. |
| 162 | pub fn from_strings(policy: &str, data_yaml: &str) -> Result<Self> { |
| 163 | let mut engine = regorus::Engine::new(); |
| 164 | engine |
| 165 | .add_policy("policy.rego".into(), policy.into()) |
| 166 | .map_err(|e| miette::miette!("{e}"))?; |
| 167 | let data_json = preprocess_yaml_data(data_yaml)?; |
| 168 | engine |
| 169 | .add_data_json(&data_json) |
| 170 | .map_err(|e| miette::miette!("{e}"))?; |
| 171 | Ok(Self { |
| 172 | engine: Mutex::new(engine), |
| 173 | generation: Arc::new(AtomicU64::new(0)), |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | /// Create OPA engine from a typed proto policy. |
| 178 | /// |
nothing calls this directly
no test coverage detected