Skip to content

Commit

Permalink
Fix Terraform formatting and add module/ prefix to path in 0-cicd-git…
Browse files Browse the repository at this point in the history
…hub 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.
  • Loading branch information
antonkovach committed Feb 19, 2023
1 parent 4ad30b8 commit 699a42e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fast/extras/0-cicd-github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
) : {
Expand Down Expand Up @@ -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 = \"[email protected]:${local.modules_repo}.git//$1${local.modules_ref}\"" # "
"/source(\\s*)=\\s*\"../../../(modules/[^/\"]+)\"/",
"source$1= \"[email protected]:${local.modules_repo}.git//$2${local.modules_ref}\"" # "
)
: file(each.value.file)
)
Expand Down

0 comments on commit 699a42e

Please sign in to comment.