mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
Add ownership snapshot sync
This commit is contained in:
parent
1e5be755ea
commit
8404b27628
13 changed files with 1415 additions and 42 deletions
|
|
@ -258,6 +258,7 @@ const KNOWN_CONFIG_KEYS: &[&str] = &[
|
|||
"cache.quote_ttl",
|
||||
"cache.fundamental_ttl",
|
||||
"ownership.db_path",
|
||||
"ownership.snapshot_manifest",
|
||||
];
|
||||
|
||||
/// Validates a config key and value before writing
|
||||
|
|
@ -302,6 +303,10 @@ fn normalize_config_value(key: &str, value: &str) -> Result<toml::Value, IdxErro
|
|||
// Ownership DB path is free-form and may be absolute or relative.
|
||||
Ok(toml::Value::String(value.to_string()))
|
||||
}
|
||||
"ownership.snapshot_manifest" => {
|
||||
// Snapshot manifest can be an absolute/relative path or a URL.
|
||||
Ok(toml::Value::String(value.to_string()))
|
||||
}
|
||||
"general.color" => {
|
||||
if !value.eq_ignore_ascii_case("true") && !value.eq_ignore_ascii_case("false") {
|
||||
return Err(IdxError::InvalidInput(format!(
|
||||
|
|
@ -556,6 +561,24 @@ mod tests {
|
|||
assert!(super::validate_config_key_value("ownership.db_path", "data/ownership.db").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_accepts_ownership_snapshot_manifest() {
|
||||
assert!(
|
||||
super::validate_config_key_value(
|
||||
"ownership.snapshot_manifest",
|
||||
"https://example.com/latest.json"
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
super::validate_config_key_value(
|
||||
"ownership.snapshot_manifest",
|
||||
"snapshots/latest.json"
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_accepts_valid_color() {
|
||||
assert!(super::validate_config_key_value("general.color", "true").is_ok());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue