Skip to content

Commit 901c5cf

Browse files
authored
Merge pull request #1100 from SteveL-MSFT/export-name
Change generated export name to only use right side of typename
2 parents 22805b5 + 73154fc commit 901c5cf

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

dsc/tests/dsc_export.tests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Describe 'resource export tests' {
4242
$config_with_process_list.metadata.'Microsoft.DSC'.operation | Should -BeExactly 'export'
4343
# contentVersion on export is always 1.0.0
4444
$config_with_process_list.contentVersion | Should -BeExactly '1.0.0'
45+
$config_with_process_list.resources.name | Should -BeLike 'Process-*'
4546
}
4647

4748
It 'Configuration Export can be piped to configuration Set' -Skip:(!$IsWindows) {
@@ -74,7 +75,7 @@ Describe 'resource export tests' {
7475
properties:
7576
pid: 0
7677
'@
77-
$out = $yaml | dsc config export -f - 2>&1
78+
$null = $yaml | dsc config export -f - 2>&1
7879
$LASTEXITCODE | Should -Be 0
7980
}
8081

dsc_lib/src/configure/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ pub fn add_resource_export_results_to_configuration(resource: &DscResource, conf
8181
.map(std::string::ToString::to_string)
8282
.ok_or_else(|| DscError::Parser(t!("configure.mod.propertyNotString", name = "_name", value = name).to_string()))?
8383
} else {
84-
format!("{}-{i}", r.resource_type)
84+
let resource_type_short = if let Some(pos) = resource.type_name.find('/') {
85+
&resource.type_name[pos + 1..]
86+
} else {
87+
&resource.type_name
88+
};
89+
format!("{resource_type_short}-{i}")
8590
};
8691
let mut metadata = Metadata {
8792
microsoft: None,

powershell-adapter/Tests/powershellgroup.resource.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ Describe 'PowerShell adapter resource tests' {
304304
$resources = $r | ConvertFrom-Json
305305
$resources.resources.count | Should -Be 2
306306
$resources.resources[0].type | Should -BeExactly 'Test/TestCase'
307-
$resources.resources[0].name | Should -BeExactly 'Test/TestCase-0'
307+
$resources.resources[0].name | Should -BeExactly 'TestCase-0'
308308
$resources.resources[0].properties.TestCaseId | Should -Be 1
309309
$resources.resources[1].type | Should -BeExactly 'Test/TestCase'
310-
$resources.resources[1].name | Should -BeExactly 'Test/TestCase-1'
310+
$resources.resources[1].name | Should -BeExactly 'TestCase-1'
311311
$resources.resources[1].properties.TestCaseId | Should -Be 2
312312
}
313313
finally {

0 commit comments

Comments
 (0)