Skip to content

Commit

Permalink
Cleanup of 'Get-DatumRsop' (#111)
Browse files Browse the repository at this point in the history
Co-authored-by: Gael <gaelcolas@users.noreply.github.com>
  • Loading branch information
raandree and gaelcolas committed Apr 8, 2021
1 parent f7ff7f5 commit f857469
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Formatting in all files with VSCode formatting according to the 'settings.json' file taken from Sampler
- Added yaml format config settings 'singleQuote' and 'bracketSpacing' and reformatted all yaml files according to the new settings.
- Cleanup
- Get-DatumRsop.ps1
- Merge-Datum.ps1
- datum.psd1
- Get-FileProviderData.ps1
Expand Down
36 changes: 21 additions & 15 deletions source/Public/Get-DatumRSOP.ps1
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
function Get-DatumRsop
{
[CmdletBinding()]
Param(
param (
[Parameter(Mandatory = $true)]
[hashtable]
$Datum,

[Parameter(Mandatory = $true)]
[hashtable[]]
$AllNodes,

[Parameter()]
[string]
$CompositionKey = 'Configurations',

[ScriptBlock]
[Parameter()]
[scriptblock]
$Filter = {}
)

if ($Filter.ToString() -ne ([System.Management.Automation.ScriptBlock]::Create( {})).ToString())
{
Write-Verbose "Filter: $($Filter.ToString())"
Write-Verbose -Message "Filter: $($Filter.ToString())"
$AllNodes = [System.Collections.Hashtable[]]$allNodes.Where($Filter)
Write-Verbose "Node count after applying filter: $($AllNodes.Count)"
Write-Verbose -Message "Node count after applying filter: $($AllNodes.Count)"
}

foreach ($Node in $AllNodes)
foreach ($node in $AllNodes)
{
$RSOPNode = $Node.clone()
$rsopNode = $node.clone()

$Configurations = Lookup $CompositionKey -Node $Node -DatumTree $Datum -DefaultValue @()
if ($RSOPNode.contains($CompositionKey))
$configurations = Lookup $CompositionKey -Node $node -DatumTree $Datum -DefaultValue @()
if ($rsopNode.contains($CompositionKey))
{
$RSOPNode[$CompositionKey] = $Configurations
$rsopNode[$CompositionKey] = $configurations
}
else
{
$RSOPNode.add($CompositionKey, $Configurations)
$rsopNode.Add($CompositionKey, $configurations)
}

$Configurations.Foreach{
if (!$RSOPNode.contains($_))
$configurations.Foreach{
if (-not $rsopNode.Contains($_))
{
$RSOPNode.Add($_, (Lookup $_ -DefaultValue @{} -Node $Node -DatumTree $Datum))
$rsopNode.Add($_, (Lookup -PropertyPath $_ -DefaultValue @{} -Node $node -DatumTree $Datum))
}
else
{
$RSOPNode[$_] = Lookup $_ -DefaultValue @{} -Node $Node -DatumTree $Datum
$rsopNode[$_] = Lookup -PropertyPath $_ -DefaultValue @{} -Node $node -DatumTree $Datum
}
}

$RSOPNode
$rsopNode
}
}

0 comments on commit f857469

Please sign in to comment.