11
11
[[ -n ${VERBOSE:- } ]] && set -x
12
12
13
13
CODER_URL=$1
14
- CONFIG_DIR=" ${PWD} /.coderv2"
14
+ DRY_RUN=" ${DRY_RUN:- 0} "
15
+ PROJECT_ROOT=" $( git rev-parse --show-toplevel) "
16
+ # shellcheck source=scripts/lib.sh
17
+ source " ${PROJECT_ROOT} /scripts/lib.sh"
18
+ CONFIG_DIR=" ${PROJECT_ROOT} /scaletest/.coderv2"
15
19
ARCH=" $( arch) "
16
20
if [[ " $ARCH " == " x86_64" ]]; then
17
21
ARCH=" amd64"
@@ -24,10 +28,10 @@ if [[ -f "${CONFIG_DIR}/coder.env" ]]; then
24
28
exit 0
25
29
fi
26
30
27
- mkdir -p " ${CONFIG_DIR} "
31
+ maybedryrun " $DRY_RUN " mkdir -p " ${CONFIG_DIR} "
28
32
echo " Fetching Coder CLI for first-time setup!"
29
- curl -fsSLk " ${CODER_URL} /bin/coder-${PLATFORM} -${ARCH} " -o " ${CONFIG_DIR} /coder"
30
- chmod +x " ${CONFIG_DIR} /coder"
33
+ maybedryrun " $DRY_RUN " curl -fsSLk " ${CODER_URL} /bin/coder-${PLATFORM} -${ARCH} " -o " ${CONFIG_DIR} /coder"
34
+ maybedryrun " $DRY_RUN " chmod +x " ${CONFIG_DIR} /coder"
31
35
32
36
set +o pipefail
33
37
RANDOM_ADMIN_PASSWORD=$( tr < /dev/urandom -dc _A-Z-a-z-0-9 | head -c16)
@@ -37,21 +41,23 @@ CODER_FIRST_USER_USERNAME="coder"
37
41
CODER_FIRST_USER_PASSWORD=" ${RANDOM_ADMIN_PASSWORD} "
38
42
CODER_FIRST_USER_TRIAL=" false"
39
43
echo " Running login command!"
40
- " ${CONFIG_DIR} /coder " login " ${CODER_URL} " \
44
+ DRY_RUN= " $DRY_RUN " " ${PROJECT_ROOT} /scaletest/lib/coder_shim.sh " login " ${CODER_URL} " \
41
45
--global-config=" ${CONFIG_DIR} " \
42
46
--first-user-username=" ${CODER_FIRST_USER_USERNAME} " \
43
47
--first-user-email=" ${CODER_FIRST_USER_EMAIL} " \
44
48
--first-user-password=" ${CODER_FIRST_USER_PASSWORD} " \
45
49
--first-user-trial=false
46
50
47
51
echo " Writing credentials to ${CONFIG_DIR} /coder.env"
48
- cat << EOF >"${CONFIG_DIR} /coder.env"
52
+ maybedryrun " $DRY_RUN " cat << EOF >"${CONFIG_DIR} /coder.env"
49
53
CODER_FIRST_USER_EMAIL=admin@coder.com
50
54
CODER_FIRST_USER_USERNAME=coder
51
55
CODER_FIRST_USER_PASSWORD="${RANDOM_ADMIN_PASSWORD} "
52
56
CODER_FIRST_USER_TRIAL="${CODER_FIRST_USER_TRIAL} "
53
57
EOF
54
58
55
59
echo " Importing kubernetes template"
56
- " ${CONFIG_DIR} /coder" templates create --global-config=" ${CONFIG_DIR} " \
57
- --directory " ${CONFIG_DIR} /templates/kubernetes" --yes kubernetes
60
+ DRY_RUN=" $DRY_RUN " " $PROJECT_ROOT /scaletest/lib/coder_shim.sh" templates create \
61
+ --global-config=" ${CONFIG_DIR} " \
62
+ --directory " ${CONFIG_DIR} /templates/kubernetes" \
63
+ --yes kubernetes
0 commit comments