Skip to content

Pathexpand all factory data paths #3033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions fast/addons/2-networking-test/factory.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
# tfdoc:file:description Factory locals.

locals {
_factory_i_data_path = pathexpand(coalesce(var.factories_config.instances, "-"))
_factory_i_data = {
for f in try(fileset(var.factories_config.instances, "*.yaml"), []) :
for f in try(fileset(local._factory_i_data_path, "*.yaml"), []) :
replace(f, ".yaml", "") => yamldecode(
file("${var.factories_config.instances}/${f}")
)
}
_factory_sa_data_path = pathexpand(coalesce(var.factories_config.service_accounts, "-"))
_factory_sa_data = {
for f in try(fileset(var.factories_config.service_accounts, "*.yaml"), []) :
for f in try(fileset(local._factory_sa_data_path, "*.yaml"), []) :
replace(f, ".yaml", "") => yamldecode(
file("${var.factories_config.service_accounts}/${f}")
)
Expand Down
3 changes: 2 additions & 1 deletion fast/stages/2-networking-a-simple/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# tfdoc:file:description Network monitoring dashboards.

locals {
dashboard_files = fileset(var.factories_config.dashboards, "*.json")
_dashboard_files_path = pathexpand(coalesce(var.factories_config.dashboards, "-"))
dashboard_files = fileset(local._dashboard_files_path, "*.json")
dashboards = {
for filename in local.dashboard_files :
filename => "${var.factories_config.dashboards}/${filename}"
Expand Down
3 changes: 2 additions & 1 deletion fast/stages/2-networking-c-separate-envs/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# tfdoc:file:description Network monitoring dashboards.

locals {
dashboard_files = fileset(var.factories_config.dashboards, "*.json")
_dashboard_files_path = pathexpand(coalesce(var.factories_config.dashboards, "-"))
dashboard_files = fileset(local._dashboard_files_path, "*.json")
dashboards = {
for filename in local.dashboard_files :
filename => "${var.factories_config.dashboards}/${filename}"
Expand Down
5 changes: 3 additions & 2 deletions modules/analytics-hub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/

locals {
prefix = var.prefix == null || var.prefix == "" ? "" : "${var.prefix}_"
prefix = var.prefix == null || var.prefix == "" ? "" : "${var.prefix}_"
_factory_listings_path = pathexpand(coalesce(var.factories_config.listings, "-"))
_factory_listings = {
for f in try(fileset(var.factories_config.listings, "*.yaml"), []) :
for f in try(fileset(local._factory_listings_path, "*.yaml"), []) :
trimsuffix(f, ".yaml") => yamldecode(
file("${var.factories_config.listings}/${f}")
)
Expand Down
3 changes: 2 additions & 1 deletion modules/data-catalog-tag/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

locals {
_factory_tag_template_path = pathexpand(coalesce(var.factories_config.tags, "-"))
_factory_tag_template = {
for f in try(fileset(var.factories_config.tags, "*.yaml"), []) :
for f in try(fileset(local._factory_tag_template_path, "*.yaml"), []) :
trimsuffix(f, ".yaml") => yamldecode(file("${var.factories_config.tags}/${f}"))
}

Expand Down
3 changes: 2 additions & 1 deletion modules/organization/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
# tfdoc:file:description IAM bindings.

locals {
_custom_roles_path = pathexpand(coalesce(var.factories_config.custom_roles, "-"))
_custom_roles = {
for f in try(fileset(var.factories_config.custom_roles, "*.yaml"), []) :
for f in try(fileset(local._custom_roles_path, "*.yaml"), []) :
replace(f, ".yaml", "") => yamldecode(
file("${var.factories_config.custom_roles}/${f}")
)
Expand Down
3 changes: 2 additions & 1 deletion modules/organization/org-policy-custom-constraints.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

locals {
_custom_constraints_factory_data_path = pathexpand(coalesce(var.factories_config.org_policy_custom_constraints, "-"))
_custom_constraints_factory_data_raw = merge([
for f in try(fileset(var.factories_config.org_policy_custom_constraints, "*.yaml"), []) :
for f in try(fileset(local._custom_constraints_factory_data_path, "*.yaml"), []) :
yamldecode(file("${var.factories_config.org_policy_custom_constraints}/${f}"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also refer the expanded path

]...)
_custom_constraints_factory_data = {
Expand Down
3 changes: 2 additions & 1 deletion modules/project/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
# - external users need to have accepted the invitation email to join

locals {
_custom_roles_path = pathexpand(coalesce(var.factories_config.custom_roles, "-"))
_custom_roles = {
for f in try(fileset(var.factories_config.custom_roles, "*.yaml"), []) :
for f in try(fileset(local._custom_roles_path, "*.yaml"), []) :
replace(f, ".yaml", "") => yamldecode(
file("${var.factories_config.custom_roles}/${f}")
)
Expand Down
3 changes: 2 additions & 1 deletion modules/project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

locals {
# descriptive_name cannot contain colons, so we omit the universe from the default
_observability_factory_data_path = pathexpand(coalesce(var.factories_config.observability, "-"))
descriptive_name = (
var.descriptive_name != null ? var.descriptive_name : "${local.prefix}${var.name}"
)
observability_factory_data_raw = [
for f in try(fileset(var.factories_config.observability, "*.yaml"), []) :
for f in try(fileset(local._observability_factory_data_path, "*.yaml"), []) :
yamldecode(file("${var.factories_config.observability}/${f}"))
]
parent_type = var.parent == null ? null : split("/", var.parent)[0]
Expand Down
3 changes: 2 additions & 1 deletion modules/project/quotas.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

locals {
_quota_factory_data_path = pathexpand(coalesce(var.factories_config.quotas, "-"))
_quota_factory_data_raw = merge([
for f in try(fileset(var.factories_config.quotas, "*.yaml"), []) :
for f in try(fileset(local._quota_factory_data_path, "*.yaml"), []) :
yamldecode(file("${var.factories_config.quotas}/${f}"))
]...)
# simulate applying defaults to data coming from yaml files
Expand Down
5 changes: 3 additions & 2 deletions modules/secops-rules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

locals {
reference_lists = try(yamldecode(file(var.factories_config.reference_lists)), var.reference_lists_config)
_secops_rules_path = pathexpand(coalesce(var.factories_config.rules_defs, "-"))
reference_lists = try(yamldecode(file(var.factories_config.reference_lists)), var.reference_lists_config)
reference_lists_entries = {
for k, v in local.reference_lists : k => split("\n", file("${var.factories_config.reference_lists_defs}/${k}.txt"))
}
Expand All @@ -25,7 +26,7 @@ locals {
CIDR = "REFERENCE_LIST_SYNTAX_TYPE_CIDR"
}
secops_rules = {
for file_name in fileset(var.factories_config.rules_defs, "*.yaral") :
for file_name in fileset(local._secops_rules_path, "*.yaral") :
replace(file_name, ".yaral", "") => file("${var.factories_config.rules_defs}/${file_name}")
}
secops_rule_deployment = try(yamldecode(file(var.factories_config.rules)), var.rules_config)
Expand Down
Loading