v0.1.0-pre.055
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: kb-config/src/settings.rs
|
||||
// version: 14
|
||||
// version: 15
|
||||
|
||||
//! Typed configuration models shared by applications and workers.
|
||||
|
||||
@@ -525,6 +525,28 @@ pub fn read_config_json_file(path: &std::path::Path) -> kb_core::Result<AppConfi
|
||||
return parse_config_json(&raw_json);
|
||||
}
|
||||
|
||||
/// Loads the workspace environment, resolves placeholders and parses one configuration file.
|
||||
pub fn read_config_json_file_with_environment(
|
||||
path: &std::path::Path,
|
||||
workspace_root: &std::path::Path,
|
||||
) -> kb_core::Result<AppConfig> {
|
||||
match crate::load_workspace_environment(workspace_root) {
|
||||
std::result::Result::Ok(_) => (),
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
}
|
||||
let raw_json = match std::fs::read_to_string(path) {
|
||||
std::result::Result::Ok(content) => content,
|
||||
std::result::Result::Err(error) => {
|
||||
return std::result::Result::Err(kb_core::Error::new(
|
||||
"config_file_read_failed",
|
||||
error.to_string(),
|
||||
));
|
||||
},
|
||||
};
|
||||
let resolved = crate::resolve_environment_placeholders(&raw_json);
|
||||
return parse_config_json(&resolved);
|
||||
}
|
||||
|
||||
/// Serializes a configuration value to compact JSON.
|
||||
pub fn serialize_config_json(config: &AppConfig) -> kb_core::Result<std::string::String> {
|
||||
match validate_config(config) {
|
||||
|
||||
Reference in New Issue
Block a user