Skip to content

Commit ceb3883

Browse files
committed
feat: Add send-secrets.sh
1 parent 60ab50c commit ceb3883

2 files changed

Lines changed: 48 additions & 4 deletions

File tree

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,33 @@ obelisk client execution submit -f obelisk-flyio:workflow/workflow@1.0.0-beta.ap
99
"$(./scripts/json-app-init-stargazers.sh)"
1010
```
1111

12+
Push secrets from `.envrc` file:
13+
```sh
14+
./scripts/send-secrets.sh .envrc
15+
```
16+
17+
List secret keys of the app:
18+
```sh
19+
obelisk client execution submit -f obelisk-flyio:activity-fly-http/secrets@1.0.0-beta.list -- \
20+
\"$FLY_APP_NAME\"
21+
```
22+
1223
Launch a VM:
1324
```sh
1425
export VOLUME_ID=..
1526
MACHINE_ID=$(obelisk client execution submit -f --json obelisk-flyio:activity-fly-http/machines@1.0.0-beta.create -- \
1627
\"$FLY_APP_NAME\" \"$FLY_MACHINE_NAME\" "$(./scripts/json-machine-create.sh)" \"$FLY_REGION\" \
17-
| jq -r '.[-1].ok.ok')
28+
| jq -r '.[-1].ok')
1829
```
1930

20-
Get the VM:
31+
Exec verify:
2132
```sh
22-
obelisk client execution submit -f obelisk-flyio:activity-fly-http/machines@1.0.0-beta.get -- \
23-
\"$FLY_APP_NAME\" \"$MACHINE_ID\"
33+
obelisk client execution submit -f \
34+
obelisk-flyio:activity-fly-http/machines@1.0.0-beta.exec \
35+
-- \
36+
\"$FLY_APP_NAME\" \
37+
\"$MACHINE_ID\" \
38+
'["obelisk", "server", "verify", "-c", "/volume/obelisk.toml"]'
2439
```
2540

2641
Delete the VM:

scripts/send-secrets.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
exec 3<&0 # save stdin as FD 3
5+
6+
FILE="${1:-.envrc}"
7+
8+
while IFS= read -r line; do
9+
# Match lines like: export foo=bar or export foo="bar"
10+
if [[ $line =~ ^export[[:space:]]+([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
11+
key="${BASH_REMATCH[1]}"
12+
val="${BASH_REMATCH[2]}"
13+
14+
# Strip surrounding quotes if any
15+
val="${val%\"}"
16+
val="${val#\"}"
17+
val="${val%\'}"
18+
val="${val#\'}"
19+
20+
echo "Found: $key"
21+
read -u 3 -p "Send to server? (y/n) " confirm
22+
if [[ "$confirm" == "y" ]]; then
23+
curl --fail localhost:9090/ \
24+
-X POST \
25+
-H "Content-Type: application/json" \
26+
-d '{"app_name":"'"$FLY_APP_NAME"'","name":"'"$key"'","value":"'"$val"'"}'
27+
fi
28+
fi
29+
done < "$FILE"

0 commit comments

Comments
 (0)