Merge pull request #1838 from GoogleCloudPlatform/wiktorn-project-factory-fix
Simplify #1836 fix, avoid map-related casting errors in project factory
This commit is contained in:
commit
0b774cc6dc
|
@ -15,18 +15,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
# turn the set of file names into a list for index-based access later on
|
_data = (
|
||||||
_factory_files = [
|
{
|
||||||
for f in fileset("${pathexpand(var.factory_data_path)}", "**/*.yaml") : f
|
for f in fileset(local._data_path, "**/*.yaml") :
|
||||||
]
|
trimsuffix(f, ".yaml") => yamldecode(file("${local._data_path}/${f}"))
|
||||||
# use a list to store data to avoid map enforcing the same type for all
|
}
|
||||||
_factory_data = [
|
)
|
||||||
for f in local._factory_files :
|
_data_path = var.factory_data_path == null ? null : pathexpand(
|
||||||
yamldecode(file("${pathexpand(var.factory_data_path)}/${f}"))
|
var.factory_data_path
|
||||||
]
|
)
|
||||||
# assemble final data, emulating optionals and using defaults and merges
|
|
||||||
projects = {
|
projects = {
|
||||||
for i, v in local._factory_data : trimsuffix(local._factory_files[i], ".yaml") => {
|
for k, v in local._data : k => merge(v, {
|
||||||
billing_account = try(coalesce(
|
billing_account = try(coalesce(
|
||||||
var.data_overrides.billing_account,
|
var.data_overrides.billing_account,
|
||||||
try(v.billing_account, null),
|
try(v.billing_account, null),
|
||||||
|
@ -95,7 +94,7 @@ locals {
|
||||||
try(v.service_accounts, null),
|
try(v.service_accounts, null),
|
||||||
var.data_defaults.service_accounts
|
var.data_defaults.service_accounts
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
service_accounts = flatten([
|
service_accounts = flatten([
|
||||||
for k, v in local.projects : [
|
for k, v in local.projects : [
|
||||||
|
|
Loading…
Reference in New Issue