Skip to content

Commit

Permalink
Merge branch 'main' into issue_592
Browse files Browse the repository at this point in the history
  • Loading branch information
anmenaga authored Jan 14, 2025
2 parents 3de6c8f + 1d8398a commit 6f63f01
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
19 changes: 19 additions & 0 deletions dsc/tests/dsc_config_get.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,23 @@ Describe 'dsc config get tests' {
}
$ProgressMessagesFound | Should -BeTrue
}

It 'contentVersion is ignored' {
$config_yaml = @"
`$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
contentVersion: 1.0.0.0
resources:
- name: Echo
type: Microsoft.DSC.Debug/Echo
properties:
output: hello
"@
$result = $config_yaml | dsc config get -f - | ConvertFrom-Json
$result.hadErrors | Should -BeFalse
$result.results.Count | Should -Be 1
$result.results[0].Name | Should -Be 'Echo'
$result.results[0].type | Should -BeExactly 'Microsoft.DSC.Debug/Echo'
$result.results[0].result.actualState.output | Should -Be 'hello'
$LASTEXITCODE | Should -Be 0
}
}
3 changes: 3 additions & 0 deletions dsc/tests/dsc_export.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Describe 'resource export tests' {

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

It 'Configuration Export can be piped to configuration Set' -Skip:(!$IsWindows) {
Expand Down
12 changes: 4 additions & 8 deletions dsc_lib/src/configure/config_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ pub struct Metadata {
pub struct Configuration {
#[serde(rename = "$schema")]
pub schema: DocumentSchemaUri,
// `contentVersion` is required by ARM, but doesn't serve a purpose here
#[serde(rename = "contentVersion")]
pub content_version: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parameters: Option<HashMap<String, Parameter>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -164,13 +165,7 @@ pub enum DocumentSchemaUri {

impl Default for Configuration {
fn default() -> Self {
Self {
schema: DocumentSchemaUri::Version2024_04,
parameters: None,
variables: None,
resources: Vec::new(),
metadata: None,
}
Self::new()
}
}

Expand All @@ -179,6 +174,7 @@ impl Configuration {
pub fn new() -> Self {
Self {
schema: DocumentSchemaUri::Version2024_04,
content_version: Some("1.0.0".to_string()),
parameters: None,
variables: None,
resources: Vec::new(),
Expand Down

0 comments on commit 6f63f01

Please sign in to comment.