MCPcopy Create free account
hub / github.com/PowerShell/DSC / convert_to_secure

Function convert_to_secure

lib/dsc-lib/src/parser/expressions.rs:243–263  ·  view source on GitHub ↗

Convert a JSON value to a secure value if it is a string or an array of strings. Arguments `value` - The JSON value to convert. Returns The converted JSON value.

(value: &Value)

Source from the content-addressed store, hash-verified

241///
242/// The converted JSON value.
243fn convert_to_secure(value: &Value) -> Value {
244 if let Some(string) = value.as_str() {
245 let secure_string = crate::configure::parameters::SecureString {
246 secure_string: string.to_string(),
247 };
248 return serde_json::to_value(secure_string).unwrap_or(value.clone());
249 }
250
251 if let Some(obj) = value.as_object() {
252 let secure_object = crate::configure::parameters::SecureObject {
253 secure_object: serde_json::Value::Object(obj.clone()),
254 };
255 return serde_json::to_value(secure_object).unwrap_or(value.clone());
256 }
257
258 if let Some(array) = value.as_array() {
259 let new_array: Vec<Value> = array.iter().map(convert_to_secure).collect();
260 return Value::Array(new_array);
261 }
262 value.clone()
263}

Callers 1

invokeMethod · 0.85

Calls 2

ArrayClass · 0.85
as_strMethod · 0.80

Tested by

no test coverage detected