Skip to content

docs(git-clone): add example for cloning multiple repositories - #1172

Closed
blinkagent[bot] wants to merge 1 commit into
mainfrom
docs/git-clone-for-each-example
Closed

blinkagent[bot] wants to merge 1 commit into
mainfrom
docs/git-clone-for-each-example

Conversation

@blinkagent

@blinkagent blinkagent Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Description

git-clone takes a single url, so cloning several repositories requires for_each on the module block. That pattern was not documented, so this adds a Clone multiple repositories section to the module README covering:

  • the basic for_each form, with the start_count check moved into the for_each expression (Terraform does not allow count and for_each on the same block)
  • per-instance isolation of scripts and logs under ~/.coder-modules/coder/git-clone/<folder_name>
  • consuming the per-key outputs, e.g. for_each = module.git_clone to create one code-server/coder_app per repository
  • a warning that two repositories with the same basename collide unless folder_name is set
  • a map-of-objects variant for per-repository branch_name / folder_name / extra_args

Documentation only, no module version bump.

Testing

Validated against the local module with Terraform 1.9.8, cloning coder/coder and coder/registry in one template:

  • terraform apply succeeds with for_each; each instance produces distinct repo_dir, folder_name, and clone_url outputs
  • running both generated coder_script payloads concurrently clones both repositories successfully, with separate scripts/ and logs/ directories per instance
  • re-running both scripts is idempotent (already exists and isn't empty, skipping clone!)
  • the map-of-objects variant with folder_name = each.key, branch_name, extra_args = ["--depth=1"], and a post_clone_script works; each instance writes its own post_clone.sh and post_clone.log
  • for_each = module.git_clone on a downstream resource resolves correctly per key
  • prettier --check passes on the README

Created on behalf of @matifali

@matifali

matifali commented Oct 9, 2026

Copy link
Copy Markdown
Member

Closing in favour of #1171

@matifali matifali closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant