Skip to content

Commit 9fb3058

Browse files
committed
fix merge conflicts
1 parent dc86114 commit 9fb3058

File tree

4 files changed

+13
-50
lines changed

4 files changed

+13
-50
lines changed

dsc/examples/groups.dsc.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resources:
99
- name: Last
1010
type: Test/Echo
1111
properties:
12-
text: Last
12+
output: Last
1313
dependsOn:
1414
- "[resourceId('DSC/Group','First Group')]"
1515
- name: First Group
@@ -20,7 +20,7 @@ resources:
2020
- name: First
2121
type: Test/Echo
2222
properties:
23-
text: First
23+
output: First
2424
- name: Nested Group
2525
type: DSC/Group
2626
properties:
@@ -29,10 +29,10 @@ resources:
2929
- name: Nested Second
3030
type: Test/Echo
3131
properties:
32-
text: Nested Second
32+
output: Nested Second
3333
dependsOn:
3434
- "[resourceId('Test/Echo','Nested First')]"
3535
- name: Nested First
3636
type: Test/Echo
3737
properties:
38-
text: Nested First
38+
output: Nested First

dsc/src/subcommand.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
use crate::args::{ConfigSubCommand, DscType, OutputFormat, ResourceSubCommand};
55
use crate::resource_command::{get_resource, self};
6+
use crate::Stream;
67
use crate::tablewriter::Table;
7-
use crate::util::{EXIT_DSC_ERROR, EXIT_INVALID_INPUT, EXIT_JSON_ERROR, EXIT_SUCCESS, EXIT_VALIDATION_FAILED, get_schema, write_output, get_input, set_dscconfigroot, validate_json};
8-
use dsc_lib::configure::config_result::ResourceGetResult;
8+
use crate::util::{EXIT_DSC_ERROR, EXIT_INVALID_INPUT, EXIT_JSON_ERROR, EXIT_VALIDATION_FAILED, get_schema, write_output, get_input, set_dscconfigroot, validate_json};
9+
use dsc_lib::configure::{Configurator, ErrorAction, config_result::ResourceGetResult};
910
use dsc_lib::dscerror::DscError;
1011
use dsc_lib::dscresources::invoke_result::{
1112
GroupResourceSetResponse, GroupResourceTestResponse, TestResult

dsc/src/util.rs

+2-40
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Licensed under the MIT License.
33

44
use crate::args::{DscType, OutputFormat, TraceFormat, TraceLevel};
5-
use jsonschema::JSONSchema;
6-
use serde_json::Value;
75

86
use atty::Stream;
97
use dsc_lib::{
@@ -26,8 +24,9 @@ use dsc_lib::{
2624
resource_manifest::ResourceManifest
2725
}
2826
};
27+
use jsonschema::JSONSchema;
2928
use schemars::{schema_for, schema::RootSchema};
30-
use serde_yaml::Value;
29+
use serde_json::Value;
3130
use std::collections::HashMap;
3231
use std::env;
3332
use std::path::Path;
@@ -420,40 +419,3 @@ pub fn set_dscconfigroot(config_path: &str)
420419
debug!("Setting 'DSCConfigRoot' env var as '{}'", config_root);
421420
env::set_var("DSCConfigRoot", config_root.clone());
422421
}
423-
424-
/// Validate the JSON against the schema.
425-
///
426-
/// # Arguments
427-
///
428-
/// * `source` - The source of the JSON
429-
/// * `schema` - The schema to validate against
430-
/// * `json` - The JSON to validate
431-
///
432-
/// # Returns
433-
///
434-
/// Nothing on success.
435-
///
436-
/// # Errors
437-
///
438-
/// * `DscError` - The JSON is invalid
439-
pub fn validate_json(source: &str, schema: &Value, json: &Value) -> Result<(), DscError> {
440-
debug!("Validating {source} against schema");
441-
debug!("JSON: {json}");
442-
debug!("Schema: {schema}");
443-
let compiled_schema = match JSONSchema::compile(schema) {
444-
Ok(compiled_schema) => compiled_schema,
445-
Err(err) => {
446-
return Err(DscError::Validation(format!("JSON Schema Compilation Error: {err}")));
447-
}
448-
};
449-
450-
if let Err(err) = compiled_schema.validate(json) {
451-
let mut error = format!("'{source}' failed validation: ");
452-
for e in err {
453-
error.push_str(&format!("\n{e} "));
454-
}
455-
return Err(DscError::Validation(error));
456-
};
457-
458-
Ok(())
459-
}

dsc/tests/dsc_group.tests.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ results:
1414
type: Test/Echo
1515
result:
1616
actualState:
17-
text: First
17+
output: First
1818
- name: Nested Group
1919
type: DSC/Group
2020
result:
2121
- name: Nested First
2222
type: Test/Echo
2323
result:
2424
actualState:
25-
text: Nested First
25+
output: Nested First
2626
- name: Nested Second
2727
type: Test/Echo
2828
result:
2929
actualState:
30-
text: Nested Second
30+
output: Nested Second
3131
- name: Last Group
3232
type: DSC/Group
3333
result:
3434
- name: Last
3535
type: Test/Echo
3636
result:
3737
actualState:
38-
text: Last
38+
output: Last
3939
messages: []
4040
hadErrors: false
4141
'@

0 commit comments

Comments
 (0)