Skip to content

Commit 56e98f0

Browse files
committed
add some magic
1 parent 6ac7bd9 commit 56e98f0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/develop.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ DEFAULT_PASSWORD="SomeSecurePassword!"
1919
password="${CODER_DEV_ADMIN_PASSWORD:-${DEFAULT_PASSWORD}}"
2020
use_proxy=0
2121
multi_org=0
22-
first_org="coder"
2322

2423
args="$(getopt -o "" -l access-url:,use-proxy,agpl,debug,password:,multi-organization -- "$@")"
2524
eval set -- "$args"
@@ -204,6 +203,8 @@ fatal() {
204203
# If we have docker available and the "docker" template doesn't already
205204
# exist, then let's try to create a template!
206205
template_name="docker"
206+
# Determine the name of the default org with some jq hax!
207+
first_org_name=$("${CODER_DEV_SHIM}" organizations show me -o json | jq -r '.[] | select(.is_default) | .name')
207208
if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then
208209
# sometimes terraform isn't installed yet when we go to create the
209210
# template
@@ -217,8 +218,8 @@ fatal() {
217218
DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')"
218219
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
219220
(
220-
echo "Pushing docker template to '${first_org}'..."
221-
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org}"
221+
echo "Pushing docker template to '${first_org_name}'..."
222+
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org_name}"
222223
if [ "${multi_org}" -gt "0" ]; then
223224
echo "Pushing docker template to '${another_org}'..."
224225
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${another_org}"

0 commit comments

Comments
 (0)