Skip to content

Commit

Permalink
Merge pull request #584 from openziti/frontdoor-catch-reserve-fail
Browse files Browse the repository at this point in the history
distinguish empty output from invalid JSON in reserve share handler
  • Loading branch information
qrkourier authored Mar 14, 2024
2 parents ecfcd7a + 7af61a1 commit 6a9a189
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nfpm/zrok-share.bash
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ if [[ "${ZROK_FRONTEND_MODE:-}" == temp-public ]]; then
exec zrok ${ZROK_CMD}
else
# reserve and continue
zrok ${ZROK_CMD} | jq -rc | tee ~/.zrok/reserved.json
zrok ${ZROK_CMD} > ~/.zrok/reserved.json
# share the reserved backend target until exit
if ! [[ -s ~/.zrok/reserved.json ]]; then
echo "ERROR: empty or missing $(realpath ~/.zrok)/reserved.json" >&2
exit 1
elif ! jq . < ~/.zrok/reserved.json &>/dev/null; then
echo "ERROR: invalid JSON in $(realpath ~/.zrok)/reserved.json" >&2
exit 1
else
ZROK_PUBLIC_URLS=$(jq -cr '.frontend_endpoints' ~/.zrok/reserved.json 2>/dev/null)
if [[ -z "${ZROK_PUBLIC_URLS}" || "${ZROK_PUBLIC_URLS}" == null ]]; then
Expand Down

0 comments on commit 6a9a189

Please sign in to comment.