From 6ac7bd9ad1a9f6659eff39e9b82f34b16cbffc8f Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 20 Nov 2024 10:35:25 +0000 Subject: [PATCH 1/4] chore(scripts/develop.sh): correct first org name when pushing initial template --- scripts/develop.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/develop.sh b/scripts/develop.sh index 7dfad72d2e9f6..0b5815e0bff1e 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -19,6 +19,7 @@ DEFAULT_PASSWORD="SomeSecurePassword!" password="${CODER_DEV_ADMIN_PASSWORD:-${DEFAULT_PASSWORD}}" use_proxy=0 multi_org=0 +first_org="coder" args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization -- "$@")" eval set -- "$args" @@ -216,8 +217,8 @@ fatal() { DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')" printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml" ( - echo "Pushing docker template to 'first-organization'..." - "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org first-organization + echo "Pushing docker template to '${first_org}'..." + "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org}" if [ "${multi_org}" -gt "0" ]; then echo "Pushing docker template to '${another_org}'..." "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${another_org}" From 56e98f08d5c02e2b5333ccea5db0d2c7958aed78 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 20 Nov 2024 10:44:45 +0000 Subject: [PATCH 2/4] add some magic --- scripts/develop.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/develop.sh b/scripts/develop.sh index 0b5815e0bff1e..5cc7bf0ac7696 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -19,7 +19,6 @@ DEFAULT_PASSWORD="SomeSecurePassword!" password="${CODER_DEV_ADMIN_PASSWORD:-${DEFAULT_PASSWORD}}" use_proxy=0 multi_org=0 -first_org="coder" args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization -- "$@")" eval set -- "$args" @@ -204,6 +203,8 @@ fatal() { # If we have docker available and the "docker" template doesn't already # exist, then let's try to create a template! template_name="docker" + # Determine the name of the default org with some jq hax! + first_org_name=$("${CODER_DEV_SHIM}" organizations show me -o json | jq -r '.[] | select(.is_default) | .name') if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then # sometimes terraform isn't installed yet when we go to create the # template @@ -217,8 +218,8 @@ fatal() { DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')" printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml" ( - echo "Pushing docker template to '${first_org}'..." - "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org}" + echo "Pushing docker template to '${first_org_name}'..." + "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org_name}" if [ "${multi_org}" -gt "0" ]; then echo "Pushing docker template to '${another_org}'..." "${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${another_org}" From 767345b340bcab11ef7d32e91bea95d08b4cf7ba Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 20 Nov 2024 10:47:34 +0000 Subject: [PATCH 3/4] peeve: run terraform init --- scripts/develop.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/develop.sh b/scripts/develop.sh index 5cc7bf0ac7696..f888de60769a1 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -214,6 +214,8 @@ fatal() { echo "Initializing docker template..." temp_template_dir="$(mktemp -d)" "${CODER_DEV_SHIM}" templates init --id "${template_name}" "${temp_template_dir}" + # Run terraform init so we get a terraform.lock.hcl + pushd "${temp_template_dir}" && terraform init && popd DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')" printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml" From f41777379e9ac4e4ef37fdb46f49fbef05220290 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 20 Nov 2024 13:09:29 +0000 Subject: [PATCH 4/4] typooooooooooooooooooooooooooooo --- scripts/develop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/develop.sh b/scripts/develop.sh index f888de60769a1..5cd2d5965f7f2 100755 --- a/scripts/develop.sh +++ b/scripts/develop.sh @@ -203,7 +203,7 @@ fatal() { # If we have docker available and the "docker" template doesn't already # exist, then let's try to create a template! template_name="docker" - # Determine the name of the default org with some jq hax! + # Determine the name of the default org with some jq hacks! first_org_name=$("${CODER_DEV_SHIM}" organizations show me -o json | jq -r '.[] | select(.is_default) | .name') if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then # sometimes terraform isn't installed yet when we go to create the