Skip to content

Commit

Permalink
Revert debug and do not hide jq errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoBrigitte committed Dec 3, 2024
1 parent 89537c9 commit 5185425
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
14 changes: 7 additions & 7 deletions bin/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ notify_discord() {
echo_stderr "$RESULT"
fi

if echo "$RESULT" | $JQ_BIN -e .message &>/dev/null; then
if echo "$RESULT" | $JQ_BIN -e .message 1>/dev/null; then
echo "$RESULT"
echo_stderr "> failed Discord notification"
else
Expand Down Expand Up @@ -107,7 +107,7 @@ notify_gotify() {
echo_stderr "$RESULT"
fi

if echo "$RESULT" | $JQ_BIN -e .error &>/dev/null; then
if echo "$RESULT" | $JQ_BIN -e .error 1>/dev/null; then
echo "$RESULT"
echo_stderr "> failed Gotify notification"
else
Expand All @@ -131,7 +131,7 @@ notify_opsgenie() {
echo_stderr "$RESULT"
fi

if echo "$RESULT" | $JQ_BIN -e '.result | length > 0' &>/dev/null; then
if echo "$RESULT" | $JQ_BIN -e '.result | length > 0' 1>/dev/null; then
echo_stderr "> sent OpsGenie notification"
else
echo "$RESULT"
Expand All @@ -158,7 +158,7 @@ notify_telegram() {
echo_stderr "$RESULT"
fi

if echo "$RESULT" | $JQ_BIN -e .ok &>/dev/null; then
if echo "$RESULT" | $JQ_BIN -e .ok 1>/dev/null; then
echo_stderr "> sent Telegram notification"
else
echo "$RESULT"
Expand All @@ -185,7 +185,7 @@ get_catalog() {
ovh_url="${OVH_API_ENDPOINTS["$ENDPOINT"]}/order/catalog/public/eco?ovhSubsidiary=${country}"
data=$(curl -qSs "${ovh_url}")

if test -z "$data" || ! echo "$data" | $JQ_BIN -e . &>/dev/null || echo "$data" | $JQ_BIN -e '.plans | length == 0' &>/dev/null; then
if test -z "$data" || ! echo "$data" | $JQ_BIN -e . 1>/dev/null || echo "$data" | $JQ_BIN -e '.plans | length == 0' 1>/dev/null; then
echo_stderr "> failed to fetch data from $ovh_url"
exit 1
fi
Expand Down Expand Up @@ -365,7 +365,7 @@ main() {
fi

# Check for error: empty data, invalid json, or empty list
if test -z "$DATA" || ! echo "$DATA" | $JQ_BIN -e . &>/dev/null || echo "$DATA" | $JQ_BIN -e '. | length == 0' &>/dev/null; then
if test -z "$DATA" || ! echo "$DATA" | $JQ_BIN -e . 1>/dev/null || echo "$DATA" | $JQ_BIN -e '. | length == 0' 1>/dev/null; then
echo "> failed to fetch data from $OVH_URL"
exit 1
fi
Expand All @@ -376,7 +376,7 @@ main() {
fi

# Check for datacenters availability
if ! echo "$DATA" | $JQ_BIN -e '.[].datacenters[] | select(.availability != "unavailable")' &>/dev/null; then
if ! echo "$DATA" | $JQ_BIN -e '.[].datacenters[] | select(.availability != "unavailable")' 1>/dev/null; then
echo_stderr "> checked $PLAN_CODE unavailable in $DATACENTERS_MESSAGE"
exit 1
fi
Expand Down
17 changes: 1 addition & 16 deletions bin/list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,8 @@ main() {
echo_stderr "> saved data to $TMP_FILE"
fi

if test -z "$DATA"; then
echo "> empty data"
exit 1
fi

if ! echo "$DATA" | $JQ_BIN -e . 1>/dev/null; then
echo "> invalid json"
exit 1
fi

if echo "$DATA" | $JQ_BIN -e '.plans | length == 0' 1>/dev/null; then
echo "> empty list"
exit 1
fi

# Check for error: empty data, invalid json, or empty list
if test -z "$DATA" || ! echo "$DATA" | $JQ_BIN -e . &>/dev/null || echo "$DATA" | $JQ_BIN -e '.plans | length == 0' &>/dev/null; then
if test -z "$DATA" || ! echo "$DATA" | $JQ_BIN -e . 1>/dev/null || echo "$DATA" | $JQ_BIN -e '.plans | length == 0' 1>/dev/null; then
echo "> failed to fetch data from $OVH_URL"
exit 1
fi
Expand Down

0 comments on commit 5185425

Please sign in to comment.