remove usage of and setting droplet number variable

while this doens't exactly feel like the Correct thing to do, there
is a benefit to not having to keep track of the state as much, and
just relying on the tags we've already set and use other places.
This commit is contained in:
ida schmidt 2025-03-30 23:05:18 +01:00
parent b25b572c35
commit 9d9451da98

View file

@ -184,7 +184,6 @@ machine(){
case $command in
create)
# read isn't used in these pipelines because of job control shinanigans
echo 'Creating Droplet...'
curl -s -X POST \
-H 'Content-Type: application/json' \
@ -195,10 +194,7 @@ machine(){
"image":"ubuntu-24-10-x64",
"ssh_keys":["'$fingerprint'"],
"tags":["auto-mc"]}' \
"https://api.digitalocean.com/v2/droplets" |\
jq .droplet.id | read droplet
export droplet
"https://api.digitalocean.com/v2/droplets" > /dev/null
echo 'Waiting for droplet to be active...'
while sleep 5; do
machine show status
@ -220,15 +216,15 @@ machine(){
curl -s -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
"https://api.digitalocean.com/v2/droplets/$droplet" |\
jq '.droplet.networks.v4[] | select(.type == "public")'
"https://api.digitalocean.com/v2/droplets?tag_name=auto-mc" |\
jq '.droplets[].networks.v4[] | select(.type == "public")'
;;
status)
curl -s -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
"https://api.digitalocean.com/v2/droplets/$droplet" |\
jq -r .droplet.status | read status
"https://api.digitalocean.com/v2/droplets?tag_name=auto-mc" |\
jq -r .droplets[].status | read status
export status
;;
esac