Skip to content

Commit

Permalink
rename to whatIf
Browse files Browse the repository at this point in the history
  • Loading branch information
tgauth committed Jun 6, 2024
1 parent 849a35e commit 857c03d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dsc_lib/src/discovery/command_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ fn load_manifest(path: &Path) -> Result<DscResource, DscError> {
capabilities.push(Capability::SetHandlesExist);
}
}
if manifest.whatif.is_some() {
if manifest.what_if.is_some() {
capabilities.push(Capability::WhatIf);
}
if manifest.test.is_some() {
Expand Down
17 changes: 10 additions & 7 deletions dsc_lib/src/dscresources/command_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,24 @@ pub fn invoke_set(resource: &ResourceManifest, cwd: &str, desired: &str, skip_te
// TODO: support import resources
let operation_type: String;
let mut is_synthetic_what_if = false;
let set = match execution_type {
let set_method = match execution_type {
ExecutionKind::Actual => {
operation_type = "set".to_string();
resource.set.clone().ok_or(DscError::NotImplemented("set".to_string()))?
&resource.set
},
ExecutionKind::WhatIf => {
operation_type = "whatif".to_string();
if let Some(whatif) = &resource.whatif {
whatif.clone()
} else {
if resource.what_if.is_none() {
is_synthetic_what_if = true;
resource.set.clone().ok_or(DscError::NotImplemented("set".to_string()))?
&resource.set
} else {
&resource.what_if
}
}
};
let Some(set) = set_method else {
return Err(DscError::NotImplemented("set".to_string()));
};
verify_json(resource, cwd, desired)?;

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

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

if resource.kind == Some(Kind::Resource) {
Expand Down
4 changes: 2 additions & 2 deletions dsc_lib/src/dscresources/resource_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub struct ResourceManifest {
#[serde(skip_serializing_if = "Option::is_none")]
pub set: Option<SetMethod>,
/// Details how to call the `WhatIf` method of the resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub whatif: Option<SetMethod>,
#[serde(rename = "whatIf", skip_serializing_if = "Option::is_none")]
pub what_if: Option<SetMethod>,
/// Details how to call the Test method of the resource.
#[serde(skip_serializing_if = "Option::is_none")]
pub test: Option<TestMethod>,
Expand Down
2 changes: 1 addition & 1 deletion tools/dsctest/dscwhatif.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"return": "state"
},
"whatif": {
"whatIf": {
"executable": "dsctest",
"args": [
"whatif",
Expand Down

0 comments on commit 857c03d

Please sign in to comment.