Use vendored JQ

This commit is contained in:
decentral1se 2021-04-07 19:49:49 +02:00
parent 9814efca5d
commit 59381e5293
No known key found for this signature in database
GPG Key ID: 92DAD76BD9567B8A
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,8 @@ The script can be run on its own like so.
$ ./abra-hetzner my-new-vps cx11 debian-10 --ssh-keys foo@example.com
```
It assumes a `$ABRA_DIR/vendor/jq` binary installation of [jq](https://stedolan.github.io/jq/tutorial/).
## Hacking
You can read the Hetzner Cloud API docs (e.g. [locations endpoint](https://docs.hetzner.cloud/#locations)).

View File

@ -108,6 +108,10 @@ declare -p "${prefix}__ssh_keys" "${prefix}__location" "${prefix}_name_" \
"${prefix}_type_" "${prefix}_image_"; done; }
# docopt parser above, complete command for generating this parser is `docopt.sh abra-hetzner`
ABRA_DIR="${ABRA_DIR:-$HOME/.abra}"
ABRA_VENDOR_DIR="$ABRA_DIR/vendor"
JQ=$ABRA_VENDOR_DIR/jq"
abra_hetzner() {
declare abra_hetzner__name_ abra_hetzner__type_ abra_hetzner__image_ \
abra_hetzner___ssh_keys abra_hetzner___location
@ -146,7 +150,7 @@ abra_hetzner() {
}" \
'https://api.hetzner.cloud/v1/servers')
ip=$(echo "$response" | jq -r ".server .public_net .ipv4 .ip")
ip=$(echo "$response" | $JQ -r ".server .public_net .ipv4 .ip")
if [[ -n "$ip" ]]; then
error_msg=$(echo "$response" | jq -r ".error .message")