Skip to content

Commit 593d659

Browse files
authored
chore(scripts/develop.sh): auto determine first org name and run terraform init (#15603)
Updates `develop.sh` to automatically determine the name of the 'first org' when pushing the initial template. Also runs `terraform init` before running `coder templates push` (pet peeve).
1 parent 6ed7692 commit 593d659

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/develop.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ fatal() {
203203
# If we have docker available and the "docker" template doesn't already
204204
# exist, then let's try to create a template!
205205
template_name="docker"
206+
# Determine the name of the default org with some jq hacks!
207+
first_org_name=$("${CODER_DEV_SHIM}" organizations show me -o json | jq -r '.[] | select(.is_default) | .name')
206208
if docker info >/dev/null 2>&1 && ! "${CODER_DEV_SHIM}" templates versions list "${template_name}" >/dev/null 2>&1; then
207209
# sometimes terraform isn't installed yet when we go to create the
208210
# template
@@ -212,12 +214,14 @@ fatal() {
212214
echo "Initializing docker template..."
213215
temp_template_dir="$(mktemp -d)"
214216
"${CODER_DEV_SHIM}" templates init --id "${template_name}" "${temp_template_dir}"
217+
# Run terraform init so we get a terraform.lock.hcl
218+
pushd "${temp_template_dir}" && terraform init && popd
215219

216220
DOCKER_HOST="$(docker context inspect --format '{{ .Endpoints.docker.Host }}')"
217221
printf 'docker_arch: "%s"\ndocker_host: "%s"\n' "${GOARCH}" "${DOCKER_HOST}" >"${temp_template_dir}/params.yaml"
218222
(
219-
echo "Pushing docker template to 'first-organization'..."
220-
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org first-organization
223+
echo "Pushing docker template to '${first_org_name}'..."
224+
"${CODER_DEV_SHIM}" templates push "${template_name}" --directory "${temp_template_dir}" --variables-file "${temp_template_dir}/params.yaml" --yes --org "${first_org_name}"
221225
if [ "${multi_org}" -gt "0" ]; then
222226
echo "Pushing docker template to '${another_org}'..."
223227
"${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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy