-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Terraform formatting and add module_prefix attribute to modules_c…
…onfig (#1162) * 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. * revert modules/ prefix change * Add module_prefix to modules_config - Add module_prefix to modules_config - Add example to Readme.md - use module_prefix variable to specify the path * fix tfdoc
- Loading branch information
1 parent
0d0a2b4
commit 5cf60cb
Showing
3 changed files
with
17 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = \"[email protected]:${local.modules_repo}.git//$1${local.modules_ref}\"" # " | ||
"/source(\\s*)=\\s*\"../../../modules/([^/\"]+)\"/", | ||
"source$1= \"[email protected]:${local.modules_repo}.git//${local.module_prefix}$2${local.modules_ref}\"" # " | ||
) | ||
: file(each.value.file) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters