diff --git a/CHANGELOG.md b/CHANGELOG.md index d27cd10..1aa33aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,3 +73,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - how sync handles pending invitations (now it does not ignore them) - removed references to other resources from for_each expressions - downgraded terraform to 1.2.9 to fix an import bug affecting for_each expressions +- refactored pages build_type assignment to trim whitespace diff --git a/terraform/locals.tf b/terraform/locals.tf index fbf0079..c05d3aa 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -122,7 +122,13 @@ locals { for file, config in lookup(config, "files", {}) : merge(config, { repository = repository file = file - content = try(file("${path.module}/../files/${config.content}"), config.content) + content = ( + try(fileexists("${path.module}/../files/${config.content}"), false) && + try(startswith( + abspath("${path.module}/../files/${config.content}"), + "${abspath("${path.module}/../files")}/" + ), false) + ) ? file("${path.module}/../files/${config.content}") : config.content }) ] ]) : lower("${item.repository}/${item.file}") => item diff --git a/terraform/resources.tf b/terraform/resources.tf index 8ba0fde..73a03cb 100644 --- a/terraform/resources.tf +++ b/terraform/resources.tf @@ -74,7 +74,7 @@ resource "github_repository" "this" { dynamic "pages" { for_each = try(each.value.pages, []) content { - build_type = try(pages.value["build_type"], null) + build_type = trimspace(try(pages.value["build_type"], "")) != "" ? pages.value["build_type"] : null cname = try(pages.value["cname"], null) dynamic "source" { for_each = pages.value["source"]