Skip to content

Commit 1d8398a

Browse files
authored
Merge pull request #621 from SteveL-MSFT/contentVersion
Add support for `contentVersion` property
2 parents a4bce18 + 95583c2 commit 1d8398a

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

dsc/tests/dsc_config_get.tests.ps1

+19
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,23 @@ Describe 'dsc config get tests' {
5555
$result.metadata.'Microsoft.DSC'.securityContext | Should -Not -BeNullOrEmpty
5656
$LASTEXITCODE | Should -Be 0
5757
}
58+
59+
It 'contentVersion is ignored' {
60+
$config_yaml = @"
61+
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
62+
contentVersion: 1.0.0.0
63+
resources:
64+
- name: Echo
65+
type: Microsoft.DSC.Debug/Echo
66+
properties:
67+
output: hello
68+
"@
69+
$result = $config_yaml | dsc config get -f - | ConvertFrom-Json
70+
$result.hadErrors | Should -BeFalse
71+
$result.results.Count | Should -Be 1
72+
$result.results[0].Name | Should -Be 'Echo'
73+
$result.results[0].type | Should -BeExactly 'Microsoft.DSC.Debug/Echo'
74+
$result.results[0].result.actualState.output | Should -Be 'hello'
75+
$LASTEXITCODE | Should -Be 0
76+
}
5877
}

dsc/tests/dsc_export.tests.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Describe 'resource export tests' {
2626

2727
$yaml = @'
2828
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
29+
contentVersion: 1.2.3
2930
resources:
3031
- name: Processes
3132
type: Microsoft/Process
@@ -39,6 +40,8 @@ Describe 'resource export tests' {
3940
$config_with_process_list.'resources' | Should -Not -BeNullOrEmpty
4041
$config_with_process_list.resources.count | Should -BeGreaterThan 1
4142
$config_with_process_list.metadata.'Microsoft.DSC'.operation | Should -BeExactly 'Export'
43+
# contentVersion on export is always 1.0.0
44+
$config_with_process_list.contentVersion | Should -BeExactly '1.0.0'
4245
}
4346

4447
It 'Configuration Export can be piped to configuration Set' -Skip:(!$IsWindows) {

dsc_lib/src/configure/config_doc.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ pub struct Metadata {
7272
pub struct Configuration {
7373
#[serde(rename = "$schema")]
7474
pub schema: DocumentSchemaUri,
75-
// `contentVersion` is required by ARM, but doesn't serve a purpose here
75+
#[serde(rename = "contentVersion")]
76+
pub content_version: Option<String>,
7677
#[serde(skip_serializing_if = "Option::is_none")]
7778
pub parameters: Option<HashMap<String, Parameter>>,
7879
#[serde(skip_serializing_if = "Option::is_none")]
@@ -164,13 +165,7 @@ pub enum DocumentSchemaUri {
164165

165166
impl Default for Configuration {
166167
fn default() -> Self {
167-
Self {
168-
schema: DocumentSchemaUri::Version2024_04,
169-
parameters: None,
170-
variables: None,
171-
resources: Vec::new(),
172-
metadata: None,
173-
}
168+
Self::new()
174169
}
175170
}
176171

@@ -179,6 +174,7 @@ impl Configuration {
179174
pub fn new() -> Self {
180175
Self {
181176
schema: DocumentSchemaUri::Version2024_04,
177+
content_version: Some("1.0.0".to_string()),
182178
parameters: None,
183179
variables: None,
184180
resources: Vec::new(),

0 commit comments

Comments
 (0)