Skip to content

Commit

Permalink
Unify usage of top level folders short_name
Browse files Browse the repository at this point in the history
  • Loading branch information
juliocc committed Nov 15, 2024
1 parent 31cb391 commit deb4ee8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 23 deletions.
3 changes: 0 additions & 3 deletions fast/stages/1-resman/data/top-level-folders/gcve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@
# yaml-language-server: $schema=../../schemas/top-level-folder.schema.json

name: GCVE
# automation is disabled since this is just a "container" for stage 3s
automation:
enable: false
3 changes: 0 additions & 3 deletions fast/stages/1-resman/data/top-level-folders/gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@
# yaml-language-server: $schema=../../schemas/top-level-folder.schema.json

name: GKE
# automation is disabled since this is just a "container" for stage 3s
automation:
enable: false
1 change: 0 additions & 1 deletion fast/stages/1-resman/data/top-level-folders/sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@

name: Sandbox
automation:
enable: true
environment_name: dev
short_name: sbox
3 changes: 0 additions & 3 deletions fast/stages/1-resman/data/top-level-folders/teams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
# yaml-language-server: $schema=../../schemas/top-level-folder.schema.json

name: Teams
# automation is disabled since this is just a "container" for the pf
automation:
enable: false
iam:
"roles/owner":
- project-factory
Expand Down
18 changes: 7 additions & 11 deletions fast/stages/1-resman/top-level-folders.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,20 @@ locals {
# extract automation configurations for folders that define them
top_level_automation = {
for k, v in local.top_level_folders :
k => merge(
{ environment_name = "prod", sa_impersonation_principals = [] },
v.automation
)
if try(v.automation.enable, null) == true
k => v.automation
if v.automation != null
}
# merge top folders from factory and variable data
top_level_folders = merge(
# normalize factory data attributes with defaults and nulls
{
for k, v in local._top_level_folders : k => merge(v, {
name = try(v.name, k)
automation = try(v.automation, {
enable = true
environment_name = "prod"
sa_impersonation_principals = []
})
automation = !can(v.automation) ? null : {
environment_name = try(v.automation.environment_name, "prod")
sa_impersonation_principals = try(v.automation.sa_impersonation_principals, [])
short_name = try(v.automation.short_name, null)
}
contacts = try(v.contacts, {})
firewall_policy = try(v.firewall_policy, null)
is_fast_context = try(v.is_fast_context, true)
Expand All @@ -62,7 +59,6 @@ locals {
iam_by_principals = try(v.iam_by_principals, {})
org_policies = try(v.org_policies, {})
parent_id = try(v.parent_id, null)
short_name = try(v.short_name, null)
tag_bindings = try(v.tag_bindings, {})
})
},
Expand Down
3 changes: 1 addition & 2 deletions fast/stages/1-resman/variables-toplevel-folders.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ variable "top_level_folders" {
name = string
parent_id = optional(string)
automation = optional(object({
enable = optional(bool, true)
environment_name = optional(string, "prod")
sa_impersonation_principals = optional(list(string), [])
short_name = optional(string)
}), {})
}))
contacts = optional(map(list(string)), {})
firewall_policy = optional(object({
name = string
Expand Down

0 comments on commit deb4ee8

Please sign in to comment.