From 699a42e5031a756eaa8398c2c884df45719444f1 Mon Sep 17 00:00:00 2001 From: Anton KOVACH <2207136+antonkovach@users.noreply.github.com> Date: Sat, 18 Feb 2023 21:08:12 +0100 Subject: [PATCH] Fix Terraform formatting and add module/ prefix to path in 0-cicd-github repository population fix the formatting of Terraform files and adds the module/ prefix to the module path in 0-cicd-github under repository population. Without proper formatting and module path, generated repositories may show formatting mismatches and examples in the README.md file may not run as expected. The changes include updating the replace function with a new regular expression pattern to correctly apply the git source for modules and updating the each.value.file attribute to include the module/ prefix in the Terraform file path. This ensures that the examples in the README.md file work as intended and that the generated repositories follow best practices for Terraform code. --- fast/extras/0-cicd-github/main.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fast/extras/0-cicd-github/main.tf b/fast/extras/0-cicd-github/main.tf index d91ab970c5..c90780244a 100644 --- a/fast/extras/0-cicd-github/main.tf +++ b/fast/extras/0-cicd-github/main.tf @@ -18,6 +18,7 @@ locals { _repository_files = flatten([ for k, v in var.repositories : [ for f in concat( + [for f in fileset(path.module, "${v.populate_from}/*.svg") : f], [for f in fileset(path.module, "${v.populate_from}/*.md") : f], [for f in fileset(path.module, "${v.populate_from}/*.tf") : f] ) : { @@ -143,8 +144,8 @@ resource "github_repository_file" "default" { endswith(each.value.name, ".tf") && local.modules_repo != null ? replace( file(each.value.file), - "/source\\s*=\\s*\"../../../modules/([^/\"]+)\"/", - "source = \"git@github.com:${local.modules_repo}.git//$1${local.modules_ref}\"" # " + "/source(\\s*)=\\s*\"../../../(modules/[^/\"]+)\"/", + "source$1= \"git@github.com:${local.modules_repo}.git//$2${local.modules_ref}\"" # " ) : file(each.value.file) )