Update module version to 1.1.0 and enhance Merge-DSCConfigurationData function to prevent modifications to sealed parameters
This commit is contained in:
@@ -20,7 +20,11 @@ function Merge-DSCConfigurationData {
|
||||
|
||||
[Parameter(Mandatory=$false, ParameterSetName="Path")]
|
||||
[switch]
|
||||
$PassThru
|
||||
$PassThru,
|
||||
|
||||
[Parameter(Mandatory=$false, ParameterSetName="Data")]
|
||||
[string]
|
||||
$MergePath = '$'
|
||||
)
|
||||
|
||||
begin {
|
||||
@@ -37,6 +41,10 @@ function Merge-DSCConfigurationData {
|
||||
$Output = $Deployment
|
||||
}
|
||||
|
||||
if((Test-ConfigurationDataNodeSealed -Node $Template) -and $Deployment.Count -gt 0){
|
||||
throw "Configuration data path [$MergePath] is sealed and cannot be modified."
|
||||
}
|
||||
|
||||
foreach($Property in $Template.GetEnumerator()){
|
||||
if($Property.Name -eq "Metadata"){
|
||||
Write-Verbose "Skipping metadata block during configuration data merge"
|
||||
@@ -47,7 +55,7 @@ function Merge-DSCConfigurationData {
|
||||
Write-Verbose "Key [$($Property.Name)] is a Dictionary"
|
||||
if(Test-ConfigurationDataDictionaryKey -Dictionary $Deployment -Key $Property.Name){
|
||||
Write-Verbose "Key [$($Property.Name)] is present in Deployment Data"
|
||||
$Output[$Property.Name] = Merge-DSCConfigurationData -Template $Template[$Property.Name] -Deployment $Deployment[$Property.Name] -Output $Output[$Property.Name]
|
||||
$Output[$Property.Name] = Merge-DSCConfigurationData -Template $Template[$Property.Name] -Deployment $Deployment[$Property.Name] -Output $Output[$Property.Name] -MergePath "$MergePath.$($Property.Name)"
|
||||
}else{
|
||||
Write-Verbose "Key [$($Property.Name)] is not present in Deployment Data"
|
||||
$Output.Add($Property.Name,(Copy-ConfigurationDataValue -Value $Template[$Property.Name]))
|
||||
@@ -89,7 +97,7 @@ function Merge-DSCConfigurationData {
|
||||
if($MatchingDeploymentItems.Count -gt 0){
|
||||
foreach($DeploymentItem in $MatchingDeploymentItems){
|
||||
$OutputItem = @($Output[$Property.Name] | Where-Object { Test-ConfigurationDataItemKeyMatch -Left $_ -Right $DeploymentItem -KeyNames $SearchKeyNames })[0]
|
||||
Merge-DSCConfigurationData -Template $TemplateItem.Value -Deployment $DeploymentItem -Output $OutputItem | Out-Null
|
||||
Merge-DSCConfigurationData -Template $TemplateItem.Value -Deployment $DeploymentItem -Output $OutputItem -MergePath "$MergePath.$($Property.Name)[$(Format-ConfigurationDataMergeKey -Item $DeploymentItem -KeyNames $SearchKeyNames)]" | Out-Null
|
||||
}
|
||||
}else{
|
||||
if($TemplateItem.IsWildcard){
|
||||
|
||||
Reference in New Issue
Block a user