Skip to content

Commit 3f98ff7

Browse files
authored
Merge pull request #1121 from tgauth/add-whatif-aliases
add aliases to --what-if
2 parents 63c868b + e6925d2 commit 3f98ff7

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

dsc/src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub enum ConfigSubCommand {
126126
file: Option<String>,
127127
#[clap(short = 'o', long, help = t!("args.outputFormat").to_string())]
128128
output_format: Option<OutputFormat>,
129-
#[clap(short = 'w', long, help = t!("args.whatIf").to_string())]
129+
#[clap(short = 'w', long, visible_aliases = ["dry-run", "noop"], help = t!("args.whatIf").to_string())]
130130
what_if: bool,
131131
},
132132
#[clap(name = "test", about = t!("args.testAbout").to_string())]

dsc/tests/dsc_whatif.tests.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ Describe 'whatif tests' {
8888
$LASTEXITCODE | Should -Be 0
8989
}
9090

91-
It 'what-if execution of WhatIf resource' {
91+
It 'what-if execution of WhatIf resource via <alias>' -TestCases @(
92+
@{ alias = '-w' }
93+
@{ alias = '--what-if' }
94+
@{ alias = '--dry-run' }
95+
@{ alias = '--noop' }
96+
) {
97+
param($alias)
9298
$config_yaml = @"
9399
`$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
94100
resources:
@@ -97,7 +103,7 @@ Describe 'whatif tests' {
97103
properties:
98104
executionType: Actual
99105
"@
100-
$result = $config_yaml | dsc config set -w -f - | ConvertFrom-Json
106+
$result = $config_yaml | dsc config set $alias -f - | ConvertFrom-Json
101107
$result.metadata.'Microsoft.DSC'.executionType | Should -BeExactly 'whatIf'
102108
$result.results.result.afterState.executionType | Should -BeExactly 'WhatIf'
103109
$result.results.result.changedProperties | Should -BeExactly 'executionType'

dsc_lib/src/functions/create_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Function for CreateObject {
3535
fn invoke(&self, args: &[Value], _context: &Context) -> Result<Value, DscError> {
3636
debug!("{}", t!("functions.createObject.invoked"));
3737

38-
if args.len() % 2 != 0 {
38+
if !args.len().is_multiple_of(2) {
3939
return Err(DscError::Parser(t!("functions.createObject.argsMustBePairs").to_string()));
4040
}
4141

dscecho/src/echo.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@ use schemars::JsonSchema;
55
use serde::{Deserialize, Serialize};
66
use serde_json::Value;
77

8-
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
9-
pub struct SecureString {
10-
#[serde(rename = "secureString")]
11-
pub value: String,
12-
}
13-
14-
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
15-
pub struct SecureObject {
16-
#[serde(rename = "secureObject")]
17-
pub value: Value,
18-
}
19-
208
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
219
#[serde(untagged)]
2210
pub enum Output {

0 commit comments

Comments
 (0)