Skip to content

Commit

Permalink
remove exists function since we cannot use not exists() check, nor a …
Browse files Browse the repository at this point in the history
…not_exists() function
  • Loading branch information
lonegunmanb committed Feb 10, 2025
1 parent 4d4b954 commit e99b175
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Azure_Proactive_Resiliency_Library_v2.Microsoft_Network_applicationGatew
import rego.v1

valid_zones(resource) if {
data.utils.exists(resource.values.body.zones)
resource.values.body.zones == resource.values.body.zones
count(resource.values.body.zones) >= 2
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ valid_outbound_rules(resource) if {
}

valid_outbound_rules(resource) if {
not resource.values.body.properties.outboundRules
not resource.values.body.properties.outboundRules == resource.values.body.properties.outboundRules
}

deny_use_nat_gateway_instead_of_outbound_rules_for_production_load_lalancer contains reason if {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Azure_Proactive_Resiliency_Library_v2.azurerm_application_gateway
import rego.v1

valid_zones(resource) if {
data.utils.exists(resource.values.zones)
resource.values.zones == resource.values.zones
count(resource.values.zones) >= 2
}

Expand Down
10 changes: 3 additions & 7 deletions policy/common/common.utils.rego
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package utils
import rego.v1

_resource(_input) := output if {
exists(_input.plan.resource_changes)
_input.plan.resource_changes == _input.plan.resource_changes
output := {
body |
r := _input.plan.resource_changes[_]
Expand All @@ -17,7 +17,7 @@ _resource(_input) := output if {
}

_resource(_input) := output if {
exists(_input.resource_changes)
_input.resource_changes == _input.resource_changes
output := {
body |
r := _input.resource_changes[_]
Expand All @@ -31,7 +31,7 @@ _resource(_input) := output if {
}

_resource(_input) := output if {
exists(_input.values.root_module.resources)
_input.values.root_module.resources == _input.values.root_module.resources
output := {
body |
r := _input.values.root_module.resources[_]
Expand All @@ -51,10 +51,6 @@ resource |
resource.type == resource_type
}

exists(x) if {
x == x
}

is_create_or_update(change_actions) if {
change_actions[count(change_actions) - 1] == ["create", "update"][_]
}
Expand Down

0 comments on commit e99b175

Please sign in to comment.