@@ -15,68 +15,70 @@ To support any infrastructure and software stack, Coder provides a generic appro
15
15
16
16
1 . Modify your template to auto-clone repos:
17
17
18
- - If you want the template to clone a specific git repo
19
-
20
- ``` hcl
21
- # Require git authentication to use this template
22
- data "coder_git_auth" "github" {
23
- id = "github"
24
- }
25
-
26
- resource "coder_agent" "dev" {
27
- # ...
28
- dir = "~/coder"
29
- startup_script =<<EOF
30
-
31
- # Clone repo from GitHub
32
- if [ ! -d "coder" ]
33
- then
34
- git clone https://github.com/coder/coder
35
- fi
36
-
37
- EOF
38
- }
39
- ```
40
-
41
- > Note: The `dir` attribute can be set in multiple ways, for example:
42
- >
43
- > - `~/coder`
44
- > - `/home/coder/coder`
45
- > - `coder` (relative to the home directory)
46
-
47
- - If you want the template to support any repository via [parameters](./parameters.md)
48
-
49
- ```hcl
50
- # Require git authentication to use this template
51
- data "coder_git_auth" "github" {
52
- id = "github"
53
- }
54
-
55
- # Prompt the user for the git repo URL
56
- data "coder_parameter" "git_repo" {
57
- name = "git_repo"
58
- display_name = "Git repository"
59
- default = "https://github.com/coder/coder"
60
- }
61
-
62
- locals {
63
- folder_name = try(element(split("/", data.coder_parameter.git_repo.value), length(split("/", data.coder_parameter.git_repo.value)) - 1), "")
64
- }
65
-
66
- resource "coder_agent" "dev" {
67
- # ...
68
- dir = "~/${local.folder_name}"
69
- startup_script =<<EOF
70
-
71
- # Clone repo from GitHub
72
- if [ ! -d "${local.folder_name}" ]
73
- then
74
- git clone ${data.coder_parameter.git_repo.value}
75
- fi
76
-
77
- EOF
78
- }
79
- ```
18
+ > The id in the template's ` coder_git_auth ` data source must match the ` CODER_GITAUTH_0_ID ` in the Coder deployment configuration.
19
+
20
+ - If you want the template to clone a specific git repo
21
+
22
+ ``` hcl
23
+ # Require git authentication to use this template
24
+ data "coder_git_auth" "github" {
25
+ id = "primary-github"
26
+ }
27
+
28
+ resource "coder_agent" "dev" {
29
+ # ...
30
+ dir = "~/coder"
31
+ startup_script =<<EOF
32
+
33
+ # Clone repo from GitHub
34
+ if [ ! -d "coder" ]
35
+ then
36
+ git clone https://github.com/coder/coder
37
+ fi
38
+
39
+ EOF
40
+ }
41
+ ```
42
+
43
+ > Note: The ` dir ` attribute can be set in multiple ways, for example:
44
+ >
45
+ > - ` ~/coder `
46
+ > - ` /home/coder/coder `
47
+ > - ` coder ` (relative to the home directory)
48
+
49
+ - If you want the template to support any repository via [ parameters] ( ./parameters.md )
50
+
51
+ ``` hcl
52
+ # Require git authentication to use this template
53
+ data "coder_git_auth" "github" {
54
+ id = "primary-github"
55
+ }
56
+
57
+ # Prompt the user for the git repo URL
58
+ data "coder_parameter" "git_repo" {
59
+ name = "git_repo"
60
+ display_name = "Git repository"
61
+ default = "https://github.com/coder/coder"
62
+ }
63
+
64
+ locals {
65
+ folder_name = try(element(split("/", data.coder_parameter.git_repo.value), length(split("/", data.coder_parameter.git_repo.value)) - 1), "")
66
+ }
67
+
68
+ resource "coder_agent" "dev" {
69
+ # ...
70
+ dir = "~/${local.folder_name}"
71
+ startup_script =<<EOF
72
+
73
+ # Clone repo from GitHub
74
+ if [ ! -d "${local.folder_name}" ]
75
+ then
76
+ git clone ${data.coder_parameter.git_repo.value}
77
+ fi
78
+
79
+ EOF
80
+ }
81
+ ```
80
82
81
83
1 . Embed the "Open in Coder" button with Markdown
82
84
0 commit comments