Skip to content

Commit

Permalink
Fixing second notScopes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
techlake committed May 6, 2024
1 parent 25849ea commit f23b32c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Docs/policy-assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Both `scope` and `notScope` are specific to an [EPAC Environment using the pacSe
`notScope` works the same. In addition `"*"` means all EPAC Environments.

```json
"notScope": {
"notScopes": {
"*": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-pattern*"
],
Expand Down
2 changes: 1 addition & 1 deletion Schemas/policy-assignment-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
}
}
},
"notScope": {
"notScopes": {
"type": "object",
"properties": {
"patternProperties": {
Expand Down
11 changes: 4 additions & 7 deletions Scripts/Helpers/Build-AssignmentDefinitionNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ function Build-AssignmentDefinitionNode {
}
else {
# may define notScope or notScopes
$definitionNotScopesList = $definition.notScopesList
if ($DefinitionNode.notScope) {
$definition.notScopesList = Add-SelectedPacArray -InputObject $DefinitionNode.notScope -PacSelector $pacSelector -ExistingList $definitionNotScopesList
Write-Warning " Node $($nodeName): notScope is legacy, consider using notScopes instead."
$definition.notScopesList = Add-SelectedPacArray -InputObject $DefinitionNode.notScope -PacSelector $pacSelector -ExistingList $definition.notScopesList
}
if ($DefinitionNode.notScopes) {
$definition.notScopesList = Add-SelectedPacArray -InputObject $DefinitionNode.notScopes -PacSelector $pacSelector -ExistingList $definitionNotScopesList
$definition.notScopesList = Add-SelectedPacArray -InputObject $DefinitionNode.notScopes -PacSelector $pacSelector -ExistingList $definition.notScopesList
}
if ($DefinitionNode.scope) {
## Found a scope list - process scope notScopes
Expand All @@ -343,7 +343,7 @@ function Build-AssignmentDefinitionNode {
$thisScopeChildren = $thisScopeDetails.childrenTable
$thisScopeGlobalNotScopeList = $thisScopeDetails.notScopesList
$thisScopeGlobalNotScopeTable = $thisScopeDetails.notScopesTable
foreach ($notScope in $definitionNotScopesList) {
foreach ($notScope in $definition.notScopesList) {
if (-not $thisScopeGlobalNotScopeTable.ContainsKey($notScope)) {
if ($thisScopeChildren.ContainsKey($notScope)) {
$null = $thisNotScopeList.Add($notScope)
Expand All @@ -355,9 +355,6 @@ function Build-AssignmentDefinitionNode {
}
}
}
else {
continue
}
}
}
$null = $thisNotScopeList.AddRange($thisScopeGlobalNotScopeList)
Expand Down

0 comments on commit f23b32c

Please sign in to comment.