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

Function set_sshd_config_repeat

resources/sshdconfig/src/set.rs:72–94  ·  view source on GitHub ↗

Handle single name-value keyword entry operations (add or remove).

(input: &str, cmd_info: &CommandInfo)

Source from the content-addressed store, hash-verified

70
71/// Handle single name-value keyword entry operations (add or remove).
72fn set_sshd_config_repeat(input: &str, cmd_info: &CommandInfo) -> Result<Map<String, Value>, SshdConfigError> {
73 let keyword_input: RepeatInput = serde_json::from_str(input)
74 .map_err(|e| SshdConfigError::InvalidInput(t!("set.failedToParse", input = e.to_string()).to_string()))?;
75
76 let (keyword, entry_value) = extract_single_keyword(keyword_input.additional_properties)?;
77
78 let mut existing_config = get_existing_config(cmd_info)?;
79
80 // parses entry for name-value keywords, like subsystem, for now
81 // different keywords will likely need to be serialized into different structs
82 // and likely need to have different add/update/remove functions
83 let entry: NameValueEntry = serde_json::from_value(entry_value)
84 .map_err(|e| SshdConfigError::InvalidInput(t!("set.failedToParse", input = e.to_string()).to_string()))?;
85
86 if keyword_input.exist {
87 add_or_update_entry(&mut existing_config, &keyword, &entry)?;
88 } else {
89 remove_entry(&mut existing_config, &keyword, &entry.name);
90 }
91
92 write_and_validate_config(&mut existing_config, cmd_info.metadata.filepath.as_ref())?;
93 Ok(Map::new())
94}
95
96/// Handle list name-value keyword operations with purge support.
97fn set_sshd_config_repeat_list(input: &str, cmd_info: &CommandInfo) -> Result<Map<String, Value>, SshdConfigError> {

Callers 1

invoke_setFunction · 0.85

Calls 8

extract_single_keywordFunction · 0.85
get_existing_configFunction · 0.85
add_or_update_entryFunction · 0.85
remove_entryFunction · 0.85
from_strFunction · 0.50
newFunction · 0.50
as_refMethod · 0.45

Tested by

no test coverage detected