Skip to content

Commit 2c0d57e

Browse files
authored
fix: update reference to agent.dev in examples and docs (#3198)
* fix: update agent ID in example templates * fix: update agent ID in dogfood template * chore: update default agent ID in documentation * fix: develop.sh: start FE after template is created; leave template dir around if template creation fails
1 parent 9a9912c commit 2c0d57e

File tree

14 files changed

+30
-27
lines changed

14 files changed

+30
-27
lines changed

docs/ides/configuring-web-ides.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ be used as a Coder application. For example:
1717
```hcl
1818
# Give template users the portainer.io web UI
1919
resource "coder_app" "portainer" {
20-
agent_id = coder_agent.dev.id
20+
agent_id = coder_agent.main.id
2121
name = "portainer"
2222
icon = "https://simpleicons.org/icons/portainer.svg"
2323
url = "http://localhost:8000"
@@ -69,7 +69,7 @@ You'll also need to specify a `coder_app` resource related to the agent. This is
6969

7070
```hcl
7171
resource "coder_app" "code-server" {
72-
agent_id = coder_agent.dev.id
72+
agent_id = coder_agent.main.id
7373
name = "code-server"
7474
url = "http://localhost:13337/?folder=/home/coder"
7575
icon = "/icon/code.svg"

dogfood/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "coder_agent" "main" {
3838
}
3939

4040
resource "coder_app" "code-server" {
41-
agent_id = coder_agent.dev.id
41+
agent_id = coder_agent.main.id
4242
name = "code-server"
4343
url = "http://localhost:13337/?folder=/home/coder"
4444
icon = "/icon/code.svg"

examples/templates/aws-linux/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Content-Transfer-Encoding: 7bit
109109
Content-Disposition: attachment; filename="userdata.txt"
110110
111111
#!/bin/bash
112-
sudo -u ${local.linux_user} sh -c '${coder_agent.dev.init_script}'
112+
sudo -u ${local.linux_user} sh -c '${coder_agent.main.init_script}'
113113
--//--
114114
EOT
115115

examples/templates/aws-windows/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ locals {
8383
user_data_start = <<EOT
8484
<powershell>
8585
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
86-
${coder_agent.dev.init_script}
86+
${coder_agent.main.init_script}
8787
</powershell>
8888
<persist>true</persist>
8989
EOT

examples/templates/bare/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ terraform {
1515
data "coder_workspace" "me" {
1616
}
1717

18-
resource "coder_agent" "dev1" {
18+
resource "coder_agent" "main" {
1919
os = "linux"
2020
arch = "amd64"
2121
auth = "token"
@@ -32,8 +32,8 @@ resource "null_resource" "fake-compute" {
3232
# Run the Coder agent init script on resources
3333
# to access web apps and SSH:
3434
#
35-
# export CODER_AGENT_TOKEN=${coder_agent.dev1.token}
36-
# ${coder_agent.dev1.init_script}
35+
# export CODER_AGENT_TOKEN=${coder_agent.main.token}
36+
# ${coder_agent.main.init_script}
3737
}
3838

3939
resource "null_resource" "fake-disk" {

examples/templates/do-linux/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ resource "digitalocean_droplet" "workspace" {
116116
user_data = templatefile("cloud-config.yaml.tftpl", {
117117
username = data.coder_workspace.me.owner
118118
home_volume_label = digitalocean_volume.home_volume.initial_filesystem_label
119-
init_script = base64encode(coder_agent.dev.init_script)
120-
coder_agent_token = coder_agent.dev.token
119+
init_script = base64encode(coder_agent.main.init_script)
120+
coder_agent_token = coder_agent.main.token
121121
})
122122
# Required to provision Fedora.
123123
ssh_keys = var.step2_do_admin_ssh_key > 0 ? [var.step2_do_admin_ssh_key] : []

examples/templates/docker-code-server/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ resource "coder_agent" "main" {
5353
}
5454

5555
resource "coder_app" "code-server" {
56-
agent_id = coder_agent.dev.id
56+
agent_id = coder_agent.main.id
5757
url = "http://localhost:8080/?folder=/home/coder"
5858
icon = "/icon/code.svg"
5959
}
@@ -70,8 +70,8 @@ resource "docker_container" "workspace" {
7070
hostname = lower(data.coder_workspace.me.name)
7171
dns = ["1.1.1.1"]
7272
# Use the docker gateway if the access URL is 127.0.0.1
73-
entrypoint = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
74-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
73+
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
74+
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
7575
host {
7676
host = "host.docker.internal"
7777
ip = "host-gateway"

examples/templates/docker-image-builds/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ resource "docker_container" "workspace" {
108108
hostname = lower(data.coder_workspace.me.name)
109109
dns = ["1.1.1.1"]
110110
# Use the docker gateway if the access URL is 127.0.0.1
111-
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
112-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
111+
command = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
112+
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
113113
host {
114114
host = "host.docker.internal"
115115
ip = "host-gateway"

examples/templates/docker-with-dotfiles/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ resource "docker_container" "workspace" {
5454
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
5555
dns = ["1.1.1.1"]
5656
# Refer to Docker host when Coder is on localhost
57-
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
58-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
57+
command = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
58+
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
5959
host {
6060
host = "host.docker.internal"
6161
ip = "host-gateway"

examples/templates/docker/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ resource "coder_agent" "main" {
8888
}
8989

9090
resource "coder_app" "code-server" {
91-
agent_id = coder_agent.dev.id
91+
agent_id = coder_agent.main.id
9292
name = "code-server"
9393
url = "http://localhost:13337/?folder=/home/coder"
9494
icon = "/icon/code.svg"
@@ -124,10 +124,10 @@ resource "docker_container" "workspace" {
124124
"sh", "-c",
125125
<<EOT
126126
trap '[ $? -ne 0 ] && echo === Agent script exited with non-zero code. Sleeping infinitely to preserve logs... && sleep infinity' EXIT
127-
${replace(coder_agent.dev.init_script, "localhost", "host.docker.internal")}
127+
${replace(coder_agent.main.init_script, "localhost", "host.docker.internal")}
128128
EOT
129129
]
130-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
130+
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
131131
host {
132132
host = "host.docker.internal"
133133
ip = "host-gateway"

examples/templates/gcp-linux/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ set -eux pipefail
7979
8080
mkdir /root || true
8181
cat <<'EOCODER' > /root/coder_agent.sh
82-
${coder_agent.dev.init_script}
82+
${coder_agent.main.init_script}
8383
EOCODER
8484
chmod +x /root/coder_agent.sh
8585

examples/templates/gcp-vm-container/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module "gce-container" {
4848
container = {
4949
image = "mcr.microsoft.com/vscode/devcontainers/go:1"
5050
command = ["sh"]
51-
args = ["-c", coder_agent.dev.init_script]
51+
args = ["-c", coder_agent.main.init_script]
5252
securityContext = {
5353
privileged : true
5454
}
@@ -85,6 +85,6 @@ resource "google_compute_instance" "dev" {
8585

8686
resource "coder_agent_instance" "dev" {
8787
count = data.coder_workspace.me.start_count
88-
agent_id = coder_agent.dev.id
88+
agent_id = coder_agent.main.id
8989
instance_id = google_compute_instance.dev[0].instance_id
9090
}

examples/templates/gcp-windows/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "google_compute_instance" "dev" {
7171
scopes = ["cloud-platform"]
7272
}
7373
metadata = {
74-
windows-startup-script-ps1 = coder_agent.dev.init_script
74+
windows-startup-script-ps1 = coder_agent.main.init_script
7575
serial-port-enable = "TRUE"
7676
}
7777
}

scripts/develop.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
4444
# rather than leaving things in an inconsistent state.
4545
trap 'kill -TERM -$$' ERR
4646
cdroot
47-
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ &
4847
"${CODER_DEV_SHIM}" server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -$$ &
4948

5049
echo '== Waiting for Coder to become ready'
@@ -68,10 +67,14 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
6867
DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}')
6968
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" | tee "${temp_template_dir}/params.yaml"
7069
template_name="docker-${GOARCH}"
71-
"${CODER_DEV_SHIM}" templates create "${template_name}" --directory "${temp_template_dir}" --parameter-file "${temp_template_dir}/params.yaml" --yes
72-
rm -rfv "${temp_template_dir}"
70+
(
71+
"${CODER_DEV_SHIM}" templates create "${template_name}" --directory "${temp_template_dir}" --parameter-file "${temp_template_dir}/params.yaml" --yes &&
72+
rm -rfv "${temp_template_dir}" # Only delete template dir if template creation succeeds
73+
) || echo "Failed to create a template. The template files are in ${temp_template_dir}"
7374
fi
7475

76+
# Start the frontend once we have a template up and running
77+
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ &
7578
log
7679
log "======================================================================="
7780
log "== =="

0 commit comments

Comments
 (0)