Skip to content

Commit 2b76fd1

Browse files
author
Andrew
committed
updated schema in dsc_default.settings.json
1 parent ebb1e96 commit 2b76fd1

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

dsc/copy_files.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
settings.dsc.json
1+
dsc.settings.json
22
dsc_default.settings.json

dsc/dsc_default.settings.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
2-
"resourcePath": {
3-
"allowEnvOverride": true,
4-
"appendEnvPath": true,
5-
"directories": []
6-
},
7-
"tracing": {
8-
"level": "WARN",
9-
"format": "Default",
10-
"allowOverride": true
2+
"1": {
3+
"resourcePath": {
4+
"allowEnvOverride": true,
5+
"appendEnvPath": true,
6+
"directories": []
7+
},
8+
"tracing": {
9+
"level": "WARN",
10+
"format": "Default",
11+
"allowOverride": true
12+
}
1113
}
1214
}

dsc_lib/src/util.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,21 @@ pub fn parse_input_to_json(value: &str) -> Result<String, DscError> {
7171
pub fn get_setting(value_name: &str) -> Result<DscSettingValue, DscError> {
7272

7373
const SETTINGS_FILE_NAME: &str = "dsc.settings.json";
74-
// Note that default settings file name has a version that is specific to this version of dsc
74+
// Note that default settings file has root nodes as settings schema version that is specific to this version of dsc
7575
const DEFAULT_SETTINGS_FILE_NAME: &str = "dsc_default.settings.json";
76+
const DEFAULT_SETTINGS_SCHEMA_VERSION: &str = "1";
7677

7778
let mut result: DscSettingValue = DscSettingValue::default();
7879
let mut settings_file_path : PathBuf;
7980

8081
if let Some(exe_home) = env::current_exe()?.parent() {
8182
// First, get setting from the default settings file
8283
settings_file_path = exe_home.join(DEFAULT_SETTINGS_FILE_NAME);
83-
if let Ok(v) = load_value_from_json(&settings_file_path, value_name) {
84-
result.setting = v;
85-
debug!("Found setting '{}' in {}", &value_name, settings_file_path.to_string_lossy());
84+
if let Ok(v) = load_value_from_json(&settings_file_path, DEFAULT_SETTINGS_SCHEMA_VERSION) {
85+
if let Some(n) = v.get(value_name) {
86+
result.setting = n.clone();
87+
debug!("Found setting '{}' in {}", &value_name, settings_file_path.to_string_lossy());
88+
}
8689
} else {
8790
debug!("Did not find setting '{}' in {}", &value_name, settings_file_path.to_string_lossy());
8891
}

0 commit comments

Comments
 (0)