Enable populating of data directory and .sample files and update dependencies
The Readme.md files reference the data directory and .sample files, but the code did not allow for their populating. This update enables the copying of the data directory and .sample files, with the data directory being populating as a data.sample directory to prevent overwriting any existing data directory. Additionally, dependencies have been updated by adding the depends_on section to several resources to ensure that the dependencies are in the correct order. This update addresses some states that were not being handled previously. There is a minor known issue with Pull Request creation in the current state of the code. The Pull Request is only created after the first run has occurred. A fix for this issue is currently being worked on and will be addressed in a separate Pull Request. However, this issue does not affect the main functionality of the code.
This commit is contained in:
parent
6ba0f8b0ba
commit
7a53511c9a
|
@ -20,11 +20,13 @@ locals {
|
|||
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}/*.sample") : f],
|
||||
[for f in fileset(path.module, "${v.populate_from}/data/**/*.*") : f],
|
||||
[for f in fileset(path.module, "${v.populate_from}/*.tf") : f]
|
||||
) : {
|
||||
repository = k
|
||||
file = f
|
||||
name = replace(f, "${v.populate_from}/", "")
|
||||
name = replace(replace(f, "${v.populate_from}/", ""), "data/", "data.sample/")
|
||||
}
|
||||
] if v.populate_from != null
|
||||
])
|
||||
|
@ -143,14 +145,18 @@ resource "github_branch" "default" {
|
|||
: {}
|
||||
)
|
||||
repository = each.key
|
||||
branch = var.pull_request_config.head_ref
|
||||
source_branch = var.pull_request_config.base_ref
|
||||
branch = var.pull_request_config.create == true ? var.pull_request_config.head_ref : "main"
|
||||
source_branch = var.pull_request_config.create == true ? var.pull_request_config.base_ref : ""
|
||||
|
||||
depends_on = [
|
||||
github_repository.default
|
||||
]
|
||||
}
|
||||
|
||||
resource "github_repository_file" "default" {
|
||||
for_each = local.modules_repo == null ? {} : local.repository_files
|
||||
repository = local.repositories[each.value.repository]
|
||||
branch = try(var.pull_request_config.head_ref, "main")
|
||||
branch = var.pull_request_config.create == true ? var.pull_request_config.head_ref : "main"
|
||||
file = each.value.name
|
||||
content = (
|
||||
endswith(each.value.name, ".tf") && local.modules_repo != null
|
||||
|
@ -171,6 +177,11 @@ resource "github_repository_file" "default" {
|
|||
content,
|
||||
]
|
||||
}
|
||||
|
||||
depends_on = [
|
||||
github_branch.default,
|
||||
github_repository.default,
|
||||
]
|
||||
}
|
||||
|
||||
resource "github_repository_pull_request" "default" {
|
||||
|
@ -184,4 +195,8 @@ resource "github_repository_pull_request" "default" {
|
|||
body = var.pull_request_config.body
|
||||
base_ref = var.pull_request_config.base_ref
|
||||
head_ref = var.pull_request_config.head_ref
|
||||
|
||||
depends_on = [
|
||||
github_repository_file.default,
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue