From 2fd9e1b46b76505de96491fb00164cb773061ec5 Mon Sep 17 00:00:00 2001 From: Mark Milligan Date: Thu, 1 Jun 2023 14:17:36 -0500 Subject: [PATCH] docs: make template git auth example in sync with git auth setup example --- docs/templates/open-in-coder.md | 126 ++++++++++++++++---------------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/docs/templates/open-in-coder.md b/docs/templates/open-in-coder.md index 6498d17b11e2a..5df13fa3f78c3 100644 --- a/docs/templates/open-in-coder.md +++ b/docs/templates/open-in-coder.md @@ -15,68 +15,70 @@ To support any infrastructure and software stack, Coder provides a generic appro 1. Modify your template to auto-clone repos: - - If you want the template to clone a specific git repo - - ```hcl - # Require git authentication to use this template - data "coder_git_auth" "github" { - id = "github" - } - - resource "coder_agent" "dev" { - # ... - dir = "~/coder" - startup_script =< Note: The `dir` attribute can be set in multiple ways, for example: - > - > - `~/coder` - > - `/home/coder/coder` - > - `coder` (relative to the home directory) - - - If you want the template to support any repository via [parameters](./parameters.md) - - ```hcl - # Require git authentication to use this template - data "coder_git_auth" "github" { - id = "github" - } - - # Prompt the user for the git repo URL - data "coder_parameter" "git_repo" { - name = "git_repo" - display_name = "Git repository" - default = "https://github.com/coder/coder" - } - - locals { - folder_name = try(element(split("/", data.coder_parameter.git_repo.value), length(split("/", data.coder_parameter.git_repo.value)) - 1), "") - } - - resource "coder_agent" "dev" { - # ... - dir = "~/${local.folder_name}" - startup_script =< The id in the template's `coder_git_auth` data source must match the `CODER_GITAUTH_0_ID` in the Coder deployment configuration. + +- If you want the template to clone a specific git repo + + ```hcl + # Require git authentication to use this template + data "coder_git_auth" "github" { + id = "primary-github" + } + + resource "coder_agent" "dev" { + # ... + dir = "~/coder" + startup_script =< Note: The `dir` attribute can be set in multiple ways, for example: + > + > - `~/coder` + > - `/home/coder/coder` + > - `coder` (relative to the home directory) + +- If you want the template to support any repository via [parameters](./parameters.md) + + ```hcl + # Require git authentication to use this template + data "coder_git_auth" "github" { + id = "primary-github" + } + + # Prompt the user for the git repo URL + data "coder_parameter" "git_repo" { + name = "git_repo" + display_name = "Git repository" + default = "https://github.com/coder/coder" + } + + locals { + folder_name = try(element(split("/", data.coder_parameter.git_repo.value), length(split("/", data.coder_parameter.git_repo.value)) - 1), "") + } + + resource "coder_agent" "dev" { + # ... + dir = "~/${local.folder_name}" + startup_script =<