Skip to content

Commit

Permalink
Fix org policies factories
Browse files Browse the repository at this point in the history
  • Loading branch information
juliocc committed Nov 17, 2022
1 parent b89e9bf commit d0c7f2d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 37 deletions.
12 changes: 4 additions & 8 deletions modules/folder/organization-policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
# tfdoc:file:description Folder-level organization policies.

locals {
_factory_data_raw = (
var.org_policies_data_path == null
? tomap({})
: merge([
for f in fileset(var.org_policies_data_path, "*.yaml") :
yamldecode(file("${var.org_policies_data_path}/${f}"))
]...)
)
_factory_data_raw = merge([
for f in try(fileset(var.org_policies_data_path, "*.yaml"), []) :
yamldecode(file("${var.org_policies_data_path}/${f}"))
]...)

# simulate applying defaults to data coming from yaml files
_factory_data = {
Expand Down
13 changes: 5 additions & 8 deletions modules/organization/org-policy-custom-constraints.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
*/

locals {
_custom_constraints_factory_data_raw = (
var.org_policy_custom_constraints_data_path == null
? tomap({})
: merge([
for f in fileset(var.org_policy_custom_constraints_data_path, "*.yaml") :
yamldecode(file("${var.org_policy_custom_constraints_data_path}/${f}"))
]...)
)
_custom_constraints_factory_data_raw = merge([
for f in try(fileset(var.org_policy_custom_constraints_data_path, "*.yaml"), []) :
yamldecode(file("${var.org_policy_custom_constraints_data_path}/${f}"))
]...)


_custom_constraints_factory_data = {
for k, v in local._custom_constraints_factory_data_raw :
Expand Down
12 changes: 4 additions & 8 deletions modules/organization/organization-policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
# tfdoc:file:description Organization-level organization policies.

locals {
_factory_data_raw = (
var.org_policies_data_path == null
? tomap({})
: merge([
for f in fileset(var.org_policies_data_path, "*.yaml") :
yamldecode(file("${var.org_policies_data_path}/${f}"))
]...)
)
_factory_data_raw = merge([
for f in try(fileset(var.org_policies_data_path, "*.yaml"), []) :
yamldecode(file("${var.org_policies_data_path}/${f}"))
]...)

# simulate applying defaults to data coming from yaml files
_factory_data = {
Expand Down
12 changes: 4 additions & 8 deletions modules/project/organization-policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
# tfdoc:file:description Project-level organization policies.

locals {
_factory_data_raw = (
var.org_policies_data_path == null
? tomap({})
: merge([
for f in fileset(var.org_policies_data_path, "*.yaml") :
yamldecode(file("${var.org_policies_data_path}/${f}"))
]...)
)
_factory_data_raw = merge([
for f in try(fileset(var.org_policies_data_path, "*.yaml"), []) :
yamldecode(file("${var.org_policies_data_path}/${f}"))
]...)

# simulate applying defaults to data coming from yaml files
_factory_data = {
Expand Down
10 changes: 5 additions & 5 deletions tests/modules/organization/test_plan_org_policies_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_policy_implementation():
'+# tfdoc:file:description Folder-level organization policies.\n',
' \n',
' locals {\n',
' _factory_data_raw = (\n',
'@@ -69,8 +69,8 @@\n',
' _factory_data_raw = merge([\n',
'@@ -65,8 +65,8 @@\n',
' org_policies = {\n',
' for k, v in local._org_policies :\n',
' k => merge(v, {\n',
Expand All @@ -64,8 +64,8 @@ def test_policy_implementation():
'+# tfdoc:file:description Organization-level organization policies.\n',
' \n',
' locals {\n',
' _factory_data_raw = (\n',
'@@ -69,8 +69,8 @@\n',
' _factory_data_raw = merge([\n',
'@@ -65,8 +65,8 @@\n',
' org_policies = {\n',
' for k, v in local._org_policies :\n',
' k => merge(v, {\n',
Expand All @@ -76,7 +76,7 @@ def test_policy_implementation():
' \n',
' is_boolean_policy = v.allow == null && v.deny == null\n',
' has_values = (\n',
'@@ -143,4 +143,13 @@\n',
'@@ -139,4 +139,13 @@\n',
' }\n',
' }\n',
' }\n',
Expand Down

0 comments on commit d0c7f2d

Please sign in to comment.