feat: add files_branch_source_branch; expand files_branch to create/u… #6
+19
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Extends the
files_branchfeature to support an update workflow for existing repositories, and adds afiles_branch_source_branchvariable so the branch can be created from a specific source ref rather than always defaulting to the repository default branch.Changes
variables.tffiles_branch_source_branch(optional string, defaultnull): the source branch used when creatingfiles_branch. Whennull, falls back tovar.github_default_branchviacoalesce().github_branch.tf&& var.create_reporestriction ongithub_branch.files_branch— the resource now creates the branch for both new repos (create_repo = true) and existing repos (create_repo = false).repositoryreference fromlocal.repo_nametolocal.repository_nameto align with other resources in the module.source_branchtocoalesce(var.files_branch_source_branch, var.github_default_branch)so callers can pass an explicit source ref (e.g. the current default branch of an existing repo).data.github_repository.existingtodepends_onso branch creation waits for the existing-repo data source in update mode.lifecycle { ignore_changes = [source_branch, source_sha] }to prevent Terraform from re-creating the branch on subsequent applies.Motivation
This change is required by
SCT-Engineering/terraform-eks-deployment#16, which implements arepository_mode = "update"workflow. In update mode no new repository is created, so the previous&& var.create_repocondition meantfiles_branchwas never created. The caller now passes:and the module handles branch creation before committing any managed files.
Testing
terraform validatepasses against the module root.terraform-eks-deploymentworkspace targeting an existing EKS cluster repo inSCT-Engineering.