Skip to content

Commit 857c03d

Browse files
committed
rename to whatIf
1 parent 849a35e commit 857c03d

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

dsc_lib/src/discovery/command_discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ fn load_manifest(path: &Path) -> Result<DscResource, DscError> {
450450
capabilities.push(Capability::SetHandlesExist);
451451
}
452452
}
453-
if manifest.whatif.is_some() {
453+
if manifest.what_if.is_some() {
454454
capabilities.push(Capability::WhatIf);
455455
}
456456
if manifest.test.is_some() {

dsc_lib/src/dscresources/command_resource.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,24 @@ pub fn invoke_set(resource: &ResourceManifest, cwd: &str, desired: &str, skip_te
9797
// TODO: support import resources
9898
let operation_type: String;
9999
let mut is_synthetic_what_if = false;
100-
let set = match execution_type {
100+
let set_method = match execution_type {
101101
ExecutionKind::Actual => {
102102
operation_type = "set".to_string();
103-
resource.set.clone().ok_or(DscError::NotImplemented("set".to_string()))?
103+
&resource.set
104104
},
105105
ExecutionKind::WhatIf => {
106106
operation_type = "whatif".to_string();
107-
if let Some(whatif) = &resource.whatif {
108-
whatif.clone()
109-
} else {
107+
if resource.what_if.is_none() {
110108
is_synthetic_what_if = true;
111-
resource.set.clone().ok_or(DscError::NotImplemented("set".to_string()))?
109+
&resource.set
110+
} else {
111+
&resource.what_if
112112
}
113113
}
114114
};
115+
let Some(set) = set_method else {
116+
return Err(DscError::NotImplemented("set".to_string()));
117+
};
115118
verify_json(resource, cwd, desired)?;
116119

117120
// if resource doesn't implement a pre-test, we execute test first to see if a set is needed
@@ -153,7 +156,7 @@ pub fn invoke_set(resource: &ResourceManifest, cwd: &str, desired: &str, skip_te
153156
let args = process_args(&get.args, desired);
154157
let command_input = get_command_input(&get.input, desired)?;
155158

156-
info!("Getting current state for {} by invoking get {} using {}", operation_type, &resource.resource_type, &get.executable);
159+
info!("Getting current state for {} by invoking get '{}' using '{}'", operation_type, &resource.resource_type, &get.executable);
157160
let (exit_code, stdout, stderr) = invoke_command(&get.executable, args, command_input.stdin.as_deref(), Some(cwd), command_input.env)?;
158161

159162
if resource.kind == Some(Kind::Resource) {

dsc_lib/src/dscresources/resource_manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ pub struct ResourceManifest {
4141
#[serde(skip_serializing_if = "Option::is_none")]
4242
pub set: Option<SetMethod>,
4343
/// Details how to call the `WhatIf` method of the resource.
44-
#[serde(skip_serializing_if = "Option::is_none")]
45-
pub whatif: Option<SetMethod>,
44+
#[serde(rename = "whatIf", skip_serializing_if = "Option::is_none")]
45+
pub what_if: Option<SetMethod>,
4646
/// Details how to call the Test method of the resource.
4747
#[serde(skip_serializing_if = "Option::is_none")]
4848
pub test: Option<TestMethod>,

tools/dsctest/dscwhatif.dsc.resource.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"return": "state"
1717
},
18-
"whatif": {
18+
"whatIf": {
1919
"executable": "dsctest",
2020
"args": [
2121
"whatif",

0 commit comments

Comments
 (0)