Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions adapters/powershell/PowerShell_adapter.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"resourceTypeArg": "-ResourceType"
},
{
"resourcePathArg": "-ResourcePath"
"resourcePathArg": "-ResourcePath",
"includeQuotes": true
Comment thread
SteveL-MSFT marked this conversation as resolved.
}
],
"input": "stdin"
Expand All @@ -61,7 +62,8 @@
"resourceTypeArg": "-ResourceType"
},
{
"resourcePathArg": "-ResourcePath"
"resourcePathArg": "-ResourcePath",
"includeQuotes": true
Comment thread
SteveL-MSFT marked this conversation as resolved.
}
],
"input": "stdin",
Expand All @@ -83,7 +85,8 @@
"resourceTypeArg": "-ResourceType"
},
{
"resourcePathArg": "-ResourcePath"
"resourcePathArg": "-ResourcePath",
"includeQuotes": true
Comment thread
SteveL-MSFT marked this conversation as resolved.
}
],
"input": "stdin",
Expand All @@ -104,7 +107,8 @@
"resourceTypeArg": "-ResourceType"
},
{
"resourcePathArg": "-ResourcePath"
"resourcePathArg": "-ResourcePath",
"includeQuotes": true
Comment thread
SteveL-MSFT marked this conversation as resolved.
}
],
"input": "stdin",
Expand Down
8 changes: 8 additions & 0 deletions dsc/tests/dsc_adapter.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ Describe 'Tests for adapter support' {
$out.schema | Should -Not -BeNullOrEmpty
}

It 'Specifying includeQuotes should include quotes for path' {
$out = dsc -l trace resource set -r Adapted/Two -i '{"two":"2"}' 2>$TestDrive/error.log | ConvertFrom-Json -Depth 10
$errorLog = Get-Content $TestDrive/error.log -Raw
$LASTEXITCODE | Should -Be 0 -Because $errorLog
$errorLog | Should -BeLike '*Invoking command ''dsctest'' with args Some(`["adapter", "--operation", "set", "--input", "{\"two\":\"2\"}", "--resource-type", "Adapted/Two", "--resource-path", "\"*\\adaptedTest.dsc.adaptedResource.json\""`])*' -Because $errorLog
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
$out.afterState.two | Should -BeExactly 'value2' -Because $errorLog
}

It 'Adapted resource with condition false should not be returned' {
$out = dsc -l debug resource list 'Adapted/Four' 2>$TestDrive/error.log
$errorLog = Get-Content $TestDrive/error.log -Raw
Expand Down
16 changes: 12 additions & 4 deletions lib/dsc-lib/src/dscresources/command_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,14 @@ pub fn process_get_args(args: Option<&Vec<GetArgKind>>, input: &str, command_res
processed_args.push(resource_type_arg.clone());
processed_args.push(command_resource_info.type_name.to_string());
},
GetArgKind::ResourcePath { resource_path_arg } => {
GetArgKind::ResourcePath { resource_path_arg , include_quotes} => {
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
if let Some(path) = &command_resource_info.path {
processed_args.push(resource_path_arg.clone());
processed_args.push(path.to_string_lossy().to_string());
if include_quotes.unwrap_or(false) {
processed_args.push(format!("\"{}\"", path.to_string_lossy()));
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
} else {
processed_args.push(path.to_string_lossy().to_string());
}
}
},
}
Expand Down Expand Up @@ -1028,10 +1032,14 @@ fn process_set_delete_args(args: Option<&Vec<SetDeleteArgKind>>, input: &str, co
processed_args.push(json_input_arg.clone());
processed_args.push(input.to_string());
},
SetDeleteArgKind::ResourcePath { resource_path_arg } => {
SetDeleteArgKind::ResourcePath { resource_path_arg , include_quotes} => {
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
if let Some(path) = &command_resource_info.path {
processed_args.push(resource_path_arg.clone());
processed_args.push(path.to_string_lossy().to_string());
if include_quotes.unwrap_or(false) {
processed_args.push(format!("\"{}\"", path.to_string_lossy()));
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
} else {
processed_args.push(path.to_string_lossy().to_string());
}
}
},
SetDeleteArgKind::ResourceType { resource_type_arg } => {
Expand Down
4 changes: 4 additions & 0 deletions lib/dsc-lib/src/dscresources/resource_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ pub enum GetArgKind {
/// The argument that accepts the resource path.
#[serde(rename = "resourcePathArg")]
resource_path_arg: String,
Comment thread
SteveL-MSFT marked this conversation as resolved.
#[serde(rename = "includeQuotes")]
include_quotes: Option<bool>,
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
},
ResourceType {
/// The argument that accepts the resource type name.
Expand All @@ -142,6 +144,8 @@ pub enum SetDeleteArgKind {
/// The argument that accepts the resource path.
#[serde(rename = "resourcePathArg")]
resource_path_arg: String,
Comment thread
SteveL-MSFT marked this conversation as resolved.
#[serde(rename = "includeQuotes")]
include_quotes: Option<bool>,
Comment thread
SteveL-MSFT marked this conversation as resolved.
Outdated
},
ResourceType {
/// The argument that accepts the resource type name.
Expand Down
4 changes: 4 additions & 0 deletions tools/dsctest/dsctest.dsc.manifests.json
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,10 @@
},
{
"resourceTypeArg": "--resource-type"
},
{
"resourcePathArg": "--resource-path",
"includeQuotes": true
}
]
},
Expand Down
Loading