Skip to content

Commit

Permalink
update checklist parsing for top-level key (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoo authored Jan 23, 2024
1 parent 37dc48b commit 4b911a6
Show file tree
Hide file tree
Showing 6 changed files with 1,478 additions and 464 deletions.
16 changes: 8 additions & 8 deletions fast/stages/0-bootstrap/checklist.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ locals {
)
# check that files are for the correct organization and ignore them if not
_cl_data = (
try(local._cl_data_raw.organization.id, null) != tostring(var.organization.id)
try(local._cl_data_raw.cloud_setup_config.organization.id, null) != tostring(var.organization.id)
? null
: local._cl_data_raw
: local._cl_data_raw.cloud_setup_config
)
_cl_org = (
try(local._cl_org_raw.organization.id, null) != tostring(var.organization.id)
try(local._cl_org_raw.cloud_setup_org_iam.organization.id, null) != tostring(var.organization.id)
? null
: local._cl_org_raw
: local._cl_org_raw.cloud_setup_org_iam
)
# do a first pass on IAM bindings to identify groups and normalize
_cl_org_iam_bindings = {
Expand Down Expand Up @@ -93,29 +93,29 @@ check "checklist" {
assert {
condition = (
var.factories_config.checklist_data == null ||
try(local._cl_data_raw.version, null) == "0.1.0"
try(local._cl_data_raw.cloud_setup_config.version, null) == "0.1.0"
)
error_message = "Checklist data version mismatch."
}
assert {
condition = (
var.factories_config.checklist_org_iam == null ||
try(local._cl_org_raw.version, null) == "0.1.0"
try(local._cl_org_raw.cloud_setup_org_iam.version, null) == "0.1.0"
)
error_message = "Checklist org IAM version mismatch."
}
# wrong org id forces us to ignore the files, but we also alert users
assert {
condition = (
var.factories_config.checklist_data == null ||
try(local._cl_data_raw.organization.id, null) == tostring(var.organization.id)
try(local._cl_data_raw.cloud_setup_config.organization.id, null) == tostring(var.organization.id)
)
error_message = "Checklist data organization id mismatch, file ignored."
}
assert {
condition = (
var.factories_config.checklist_org_iam == null ||
try(local._cl_org_raw.organization.id, null) == tostring(var.organization.id)
try(local._cl_org_raw.cloud_setup_org_iam.organization.id, null) == tostring(var.organization.id)
)
error_message = "Checklist org IAM organization id mismatch, file ignored."
}
Expand Down
8 changes: 4 additions & 4 deletions fast/stages/1-resman/checklist.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ locals {
)
# check that files are for the correct organization and ignore them if not
_cl_data = (
try(local._cl_data_raw.organization.id, null) != tostring(var.organization.id)
try(local._cl_data_raw.cloud_setup_config.organization.id, null) != tostring(var.organization.id)
? null
: local._cl_data_raw
: local._cl_data_raw.cloud_setup_config
)
# normalized IAM bindings one element per binding
_cl_iam = local._cl_data == null ? [] : flatten([
Expand Down Expand Up @@ -57,15 +57,15 @@ check "checklist" {
assert {
condition = (
var.factories_config.checklist_data == null ||
try(local._cl_data_raw.version, null) == "0.1.0"
try(local._cl_data_raw.cloud_setup_config.version, null) == "0.1.0"
)
error_message = "Checklist data version mismatch."
}
# wrong org id forces us to ignore the files, but we also alert users
assert {
condition = (
var.factories_config.checklist_data == null ||
try(local._cl_data_raw.organization.id, null) == tostring(var.organization.id)
try(local._cl_data_raw.cloud_setup_config.organization.id, null) == tostring(var.organization.id)
)
error_message = "Checklist data organization id mismatch, file ignored."
}
Expand Down
Loading

0 comments on commit 4b911a6

Please sign in to comment.