Files
kydah-modules/ak-gatekeeper/outpost_read.sh
2024-10-08 16:41:52 +02:00

22 lines
519 B
Bash

#!/bin/bash
set -e
CURL_OPTIONS="-sL"
if [ ! -z ${INSECURE_CURL+x} ]; then
CURL_OPTIONS="${CURL_OPTIONS} -k"
fi
OUTPUT_FILE=$(mktemp)
HTTP_CODE=$(curl $CURL_OPTIONS \
--output $OUTPUT_FILE \
--write-out "%{http_code}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${AK_TOKEN}" \
"${AK_BASEURL}/api/v3/outposts/instances/${AK_OUTPOST_ID}/")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]] ; then
>&2 cat $OUTPUT_FILE
rm $OUTPUT_FILE
exit 2
fi
cat | jq -r ".results"
rm $OUTPUT_FILE