Delete redundant code
This commit is contained in:
1 parent
5bc3142249
commit
4b9bb22c87
2 files changed
+1
-21
No files matched your search
@@ -1184,22 +1184,6 @@ pub(crate) fn yaml_edit_node_from_value(
|
||||
.ok_or_else(|| "Unable to construct kernel configuration value".to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn set_core_yaml_top_level_value(
|
||||
document: &mut serde_norway::Value,
|
||||
key: &str,
|
||||
value: serde_norway::Value,
|
||||
) -> Result<bool, String> {
|
||||
let root = document
|
||||
.as_mapping_mut()
|
||||
.ok_or_else(|| "Kernel configuration root must be a YAML mapping".to_string())?;
|
||||
let key = yaml_key(key);
|
||||
if root.get(&key) == Some(&value) {
|
||||
return Ok(false);
|
||||
}
|
||||
root.insert(key, value);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
pub(crate) fn set_core_yaml_nested_value(
|
||||
document: &mut serde_norway::Value,
|
||||
section: &str,
|
||||
|
||||
@@ -1264,11 +1264,7 @@ fn yaml_edit_sequence_shrink_keeps_following_top_level_key_valid() {
|
||||
fn runtime_yaml_ast_patch_handles_core_comments_around_nested_mapping() {
|
||||
let input = "host: 127.0.0.1\nremote-management:\n# Whether to allow remote access.\n allow-remote: false\n# Management key.\n# All requests require this key.\n secret-key: old\n# Disable panel.\n disable-control-panel: false\nauth-dir: /tmp/old\napi-keys:\n - old-key\n";
|
||||
let rendered = patch_core_yaml_document(input, |document| {
|
||||
let auth_changed = set_core_yaml_top_level_value(
|
||||
document,
|
||||
"auth-dir",
|
||||
serde_norway::Value::String("/tmp/new".to_string()),
|
||||
)?;
|
||||
let auth_changed = set_core_yaml_auth_dir(document, "/tmp/new")?;
|
||||
let secret_changed = set_core_yaml_nested_value(
|
||||
document,
|
||||
"remote-management",
|
||||
|
||||
Reference in new issue
Block a user