MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / from_strings

Method from_strings

crates/openshell-supervisor-network/src/opa.rs:162–175  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers

nothing calls this directly

Calls 1

preprocess_yaml_dataFunction · 0.85

Tested by

no test coverage detected