config_from_string() changed to data_from_string()
This commit is contained in:
@@ -251,7 +251,7 @@ impl Default for ItemData {
|
|||||||
|
|
||||||
pub fn data_from_string(data_string: String) -> MizeResult<ItemData> {
|
pub fn data_from_string(data_string: String) -> MizeResult<ItemData> {
|
||||||
|
|
||||||
let mut config = ItemData::new();
|
let mut data = ItemData::new();
|
||||||
|
|
||||||
// in case it's just a string
|
// in case it's just a string
|
||||||
if !data_string.contains("=") {
|
if !data_string.contains("=") {
|
||||||
@@ -268,13 +268,13 @@ pub fn data_from_string(data_string: String) -> MizeResult<ItemData> {
|
|||||||
.ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty path (thing beforee =)", option)))?;
|
.ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty path (thing beforee =)", option)))?;
|
||||||
let value = option.split("=").nth(1)
|
let value = option.split("=").nth(1)
|
||||||
.ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty value (thing after =)", option)))?;
|
.ok_or(MizeError::new().msg(format!("Failed to parse Option: option '{}' has an empty value (thing after =)", option)))?;
|
||||||
let mut path_vec = vec!["config"];
|
let mut path_vec = Vec::new();
|
||||||
path_vec.extend(path.split("."));
|
path_vec.extend(path.split("."));
|
||||||
|
|
||||||
config.set_path(path_vec, ItemData::parse(value))?;
|
data.set_path(path_vec, ItemData::parse(value))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(config);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn item_data_get_path(data: &CborValue, path: Vec<String>) -> MizeResult<&CborValue> {
|
pub fn item_data_get_path(data: &CborValue, path: Vec<String>) -> MizeResult<&CborValue> {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
|||||||
Ok(config_string) => {
|
Ok(config_string) => {
|
||||||
let config = data_from_string(config_string)?;
|
let config = data_from_string(config_string)?;
|
||||||
debug!("env var MIZE_CONFIG present");
|
debug!("env var MIZE_CONFIG present");
|
||||||
instance.set_blocking("0", config)?;
|
instance.set_blocking("0/config", config)?;
|
||||||
trace!("config after MIZE_CONFIG env var: {}", instance.get("0/config")?);
|
trace!("config after MIZE_CONFIG env var: {}", instance.get("0/config")?);
|
||||||
}
|
}
|
||||||
Err(var_err) => match var_err {
|
Err(var_err) => match var_err {
|
||||||
|
|||||||
Reference in New Issue
Block a user