From b623348d27e6cb294622f839b7d783052e53968f Mon Sep 17 00:00:00 2001 From: galargh Date: Thu, 5 May 2022 18:38:40 +0200 Subject: [PATCH] add a comment with repository_file optimization --- terraform/data.tf | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/terraform/data.tf b/terraform/data.tf index 0245efb..0e819ec 100644 --- a/terraform/data.tf +++ b/terraform/data.tf @@ -28,6 +28,31 @@ data "github_repository" "this" { # @resources.team_membership.data data "github_organization_teams" "this" {} +# once https://github.com/integrations/terraform-provider-github/issues/1131 is resolved +# we can replace data.github_branch.this and data.github_tree.this with the following: +# data "github_repository_file" "this" { +# for_each = merge([ +# for repository, files in lookup(local.github, "repository_file", {}) : +# { +# for file, config in { +# for file, config in files : +# file => merge({ +# branch = lookup(config, "branch", data.github_repository.this[repository].default_branch) +# }, config) if contains(keys(data.github_repository.this), repository) +# } : +# "${repository}/${file}:${config.branch}" => { +# repository = repository +# file = file +# branch = config.branch +# } +# } +# ]...) +# +# repository = each.value.repository +# file = each.value.file +# branch = each.value.branch +# } + data "github_branch" "this" { for_each = merge([ for repository, files in lookup(local.github, "repository_file", {}) : @@ -55,5 +80,5 @@ data "github_tree" "this" { recursive = true repository = each.value.repository - tree_sha = data.value.sha + tree_sha = each.value.sha }