Skip to content

fix: update reference to agent.dev in examples and docs #3198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ides/configuring-web-ides.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ be used as a Coder application. For example:
```hcl
# Give template users the portainer.io web UI
resource "coder_app" "portainer" {
agent_id = coder_agent.dev.id
agent_id = coder_agent.main.id
name = "portainer"
icon = "https://simpleicons.org/icons/portainer.svg"
url = "http://localhost:8000"
Expand Down Expand Up @@ -69,7 +69,7 @@ You'll also need to specify a `coder_app` resource related to the agent. This is

```hcl
resource "coder_app" "code-server" {
agent_id = coder_agent.dev.id
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
Expand Down
2 changes: 1 addition & 1 deletion dogfood/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.dev.id
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/aws-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"

#!/bin/bash
sudo -u ${local.linux_user} sh -c '${coder_agent.dev.init_script}'
sudo -u ${local.linux_user} sh -c '${coder_agent.main.init_script}'
--//--
EOT

Expand Down
2 changes: 1 addition & 1 deletion examples/templates/aws-windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ locals {
user_data_start = <<EOT
<powershell>
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
${coder_agent.dev.init_script}
${coder_agent.main.init_script}
</powershell>
<persist>true</persist>
EOT
Expand Down
6 changes: 3 additions & 3 deletions examples/templates/bare/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ terraform {
data "coder_workspace" "me" {
}

resource "coder_agent" "dev1" {
resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
auth = "token"
Expand All @@ -32,8 +32,8 @@ resource "null_resource" "fake-compute" {
# Run the Coder agent init script on resources
# to access web apps and SSH:
#
# export CODER_AGENT_TOKEN=${coder_agent.dev1.token}
# ${coder_agent.dev1.init_script}
# export CODER_AGENT_TOKEN=${coder_agent.main.token}
# ${coder_agent.main.init_script}
}

resource "null_resource" "fake-disk" {
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/do-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ resource "digitalocean_droplet" "workspace" {
user_data = templatefile("cloud-config.yaml.tftpl", {
username = data.coder_workspace.me.owner
home_volume_label = digitalocean_volume.home_volume.initial_filesystem_label
init_script = base64encode(coder_agent.dev.init_script)
coder_agent_token = coder_agent.dev.token
init_script = base64encode(coder_agent.main.init_script)
coder_agent_token = coder_agent.main.token
})
# Required to provision Fedora.
ssh_keys = var.step2_do_admin_ssh_key > 0 ? [var.step2_do_admin_ssh_key] : []
Expand Down
6 changes: 3 additions & 3 deletions examples/templates/docker-code-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.dev.id
agent_id = coder_agent.main.id
url = "http://localhost:8080/?folder=/home/coder"
icon = "/icon/code.svg"
}
Expand All @@ -70,8 +70,8 @@ resource "docker_container" "workspace" {
hostname = lower(data.coder_workspace.me.name)
dns = ["1.1.1.1"]
# Use the docker gateway if the access URL is 127.0.0.1
entrypoint = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
host {
host = "host.docker.internal"
ip = "host-gateway"
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/docker-image-builds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ resource "docker_container" "workspace" {
hostname = lower(data.coder_workspace.me.name)
dns = ["1.1.1.1"]
# Use the docker gateway if the access URL is 127.0.0.1
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
command = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
host {
host = "host.docker.internal"
ip = "host-gateway"
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/docker-with-dotfiles/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ resource "docker_container" "workspace" {
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
dns = ["1.1.1.1"]
# Refer to Docker host when Coder is on localhost
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
command = ["sh", "-c", replace(coder_agent.main.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
host {
host = "host.docker.internal"
ip = "host-gateway"
Expand Down
6 changes: 3 additions & 3 deletions examples/templates/docker/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ resource "coder_agent" "main" {
}

resource "coder_app" "code-server" {
agent_id = coder_agent.dev.id
agent_id = coder_agent.main.id
name = "code-server"
url = "http://localhost:13337/?folder=/home/coder"
icon = "/icon/code.svg"
Expand Down Expand Up @@ -124,10 +124,10 @@ resource "docker_container" "workspace" {
"sh", "-c",
<<EOT
trap '[ $? -ne 0 ] && echo === Agent script exited with non-zero code. Sleeping infinitely to preserve logs... && sleep infinity' EXIT
${replace(coder_agent.dev.init_script, "localhost", "host.docker.internal")}
${replace(coder_agent.main.init_script, "localhost", "host.docker.internal")}
EOT
]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
host {
host = "host.docker.internal"
ip = "host-gateway"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/gcp-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ set -eux pipefail

mkdir /root || true
cat <<'EOCODER' > /root/coder_agent.sh
${coder_agent.dev.init_script}
${coder_agent.main.init_script}
EOCODER
chmod +x /root/coder_agent.sh

Expand Down
4 changes: 2 additions & 2 deletions examples/templates/gcp-vm-container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module "gce-container" {
container = {
image = "mcr.microsoft.com/vscode/devcontainers/go:1"
command = ["sh"]
args = ["-c", coder_agent.dev.init_script]
args = ["-c", coder_agent.main.init_script]
securityContext = {
privileged : true
}
Expand Down Expand Up @@ -85,6 +85,6 @@ resource "google_compute_instance" "dev" {

resource "coder_agent_instance" "dev" {
count = data.coder_workspace.me.start_count
agent_id = coder_agent.dev.id
agent_id = coder_agent.main.id
instance_id = google_compute_instance.dev[0].instance_id
}
2 changes: 1 addition & 1 deletion examples/templates/gcp-windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ resource "google_compute_instance" "dev" {
scopes = ["cloud-platform"]
}
metadata = {
windows-startup-script-ps1 = coder_agent.dev.init_script
windows-startup-script-ps1 = coder_agent.main.init_script
serial-port-enable = "TRUE"
}
}
9 changes: 6 additions & 3 deletions scripts/develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
# rather than leaving things in an inconsistent state.
trap 'kill -TERM -$$' ERR
cdroot
CODER_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -$$ &
"${CODER_DEV_SHIM}" server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -$$ &

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

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