unoverse 0.1.58 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/operator/lib/deploy.sh +30 -1
- package/package.json +1 -1
package/operator/lib/deploy.sh
CHANGED
|
@@ -5,6 +5,19 @@ cmd_deploy() {
|
|
|
5
5
|
|
|
6
6
|
local env_prod="$ROOT/.env.production"
|
|
7
7
|
|
|
8
|
+
# HAND TERRAFORM ITS TOKEN. By design the DO token lives in doctl's config and never
|
|
9
|
+
# in a repo file (main.tf: empty var falls through to DIGITALOCEAN_TOKEN). deploy
|
|
10
|
+
# authenticated doctl, so deploy passes the token on — process env only, no file.
|
|
11
|
+
# Without this, apply planned 6 resources and then 401'd on an empty credential.
|
|
12
|
+
if [ -z "${DIGITALOCEAN_TOKEN:-}" ]; then
|
|
13
|
+
local _docfg
|
|
14
|
+
for _docfg in "$HOME/Library/Application Support/doctl/config.yaml" "$HOME/.config/doctl/config.yaml"; do
|
|
15
|
+
[ -f "$_docfg" ] || continue
|
|
16
|
+
DIGITALOCEAN_TOKEN=$(awk '/access-token:/{print $2; exit}' "$_docfg")
|
|
17
|
+
if [ -n "$DIGITALOCEAN_TOKEN" ]; then export DIGITALOCEAN_TOKEN; break; fi
|
|
18
|
+
done
|
|
19
|
+
fi
|
|
20
|
+
|
|
8
21
|
# Missing .env.production is not an error if a ground has been applied — the
|
|
9
22
|
# file is just a Terraform output, so render it ourselves. Reading state is
|
|
10
23
|
# not wrapping terraform: apply stays the developer's explicit act.
|
|
@@ -106,7 +119,23 @@ cmd_deploy() {
|
|
|
106
119
|
info "When ready: cd infra/$cloud && terraform init && terraform apply && cd ../.. && unoverse deploy"
|
|
107
120
|
exit 0
|
|
108
121
|
fi
|
|
109
|
-
|
|
122
|
+
# Terraform is one static binary: install it directly from the official release
|
|
123
|
+
# rather than sending anyone to brew (whose compile chain can demand Xcode Command
|
|
124
|
+
# Line Tools updates for a tool that needs no compiling).
|
|
125
|
+
if ! command -v terraform >/dev/null 2>&1; then
|
|
126
|
+
local REPLY2 tf_arch tf_os tf_v="1.9.8" tf_dir
|
|
127
|
+
read -r -p " Terraform is needed. Install it now (official binary, ~30 MB)? [Y/n] " REPLY2
|
|
128
|
+
[[ "$REPLY2" =~ ^[Nn]$ ]] && { fail "terraform is needed to continue"; exit 1; }
|
|
129
|
+
tf_arch=$(uname -m); [ "$tf_arch" = "arm64" ] || [ "$tf_arch" = "aarch64" ] && tf_arch=arm64 || tf_arch=amd64
|
|
130
|
+
[ "$(uname -s)" = "Darwin" ] && tf_os=darwin || tf_os=linux
|
|
131
|
+
tf_dir=$(mktemp -d)
|
|
132
|
+
curl -fsSL -o "$tf_dir/tf.zip" "https://releases.hashicorp.com/terraform/${tf_v}/terraform_${tf_v}_${tf_os}_${tf_arch}.zip" && unzip -o -q "$tf_dir/tf.zip" -d "$tf_dir" || { fail "download failed"; exit 1; }
|
|
133
|
+
if [ -w /usr/local/bin ]; then mv "$tf_dir/terraform" /usr/local/bin/terraform
|
|
134
|
+
else sudo mv "$tf_dir/terraform" /usr/local/bin/terraform || { fail "could not install to /usr/local/bin"; exit 1; }
|
|
135
|
+
fi
|
|
136
|
+
rm -rf "$tf_dir"
|
|
137
|
+
ok "terraform $(terraform version | head -1 | awk '{print $2}') installed"
|
|
138
|
+
fi
|
|
110
139
|
terraform -chdir="$ROOT/infra/$cloud" init -input=false >/dev/null 2>&1 || { fail "terraform init failed"; exit 1; }
|
|
111
140
|
terraform -chdir="$ROOT/infra/$cloud" apply || { fail "apply did not complete. Re-run: unoverse deploy"; exit 1; }
|
|
112
141
|
echo ""
|
package/package.json
CHANGED