use std::collections::BTreeSet;
use crate::error::ConfigError;
use crate::loader::path::try_normalize_external_path;
pub(super) fn normalize_secret_registration_paths(
secret_paths: &BTreeSet<String>,
) -> Result<BTreeSet<String>, ConfigError> {
secret_paths
.iter()
.map(|path| normalize_secret_registration_path(path))
.collect()
}
fn normalize_secret_registration_path(path: &str) -> Result<String, ConfigError> {
let normalized =
try_normalize_external_path(path).map_err(|message| ConfigError::MetadataInvalid {
path: path.to_owned(),
message: format!("invalid secret path: {message}"),
})?;
if normalized.is_empty() {
return Err(ConfigError::MetadataInvalid {
path: path.to_owned(),
message: "invalid secret path: configuration path cannot be empty".to_owned(),
});
}
Ok(normalized)
}