-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrote shell code with focus on improved readability
- Loading branch information
Showing
4 changed files
with
197 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
set -e | ||
set -ueo pipefail | ||
|
||
exec 3>&1 # make stdout available as fd 3 for the result | ||
exec 1>&2 # redirect all output to stderr for logging | ||
|
||
PAYLOAD=$(mktemp /tmp/resource-check.XXXXXX) | ||
payload=$(cat <&0) | ||
|
||
cat > "$PAYLOAD" <&0 | ||
timestamp=$(jq --raw-output '.version.timestamp // empty' <<< "${payload}") | ||
|
||
TS=$(jq '.version.timestamp // empty' < "$PAYLOAD") | ||
|
||
if [ -z "$TS" ]; then | ||
if [[ -z "${timestamp}" ]]; then | ||
echo '[]' >&3 | ||
else | ||
jq -n "[ | ||
{ timestamp: $TS } | ||
]" >&3 | ||
jq --null-input \ | ||
--arg "timestamp" "${timestamp}" \ | ||
'[ { timestamp: $timestamp } ]' \ | ||
>&3 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
set -e | ||
set -ueo pipefail | ||
|
||
exec 3>&1 # make stdout available as fd 3 for the result | ||
exec 1>&2 # redirect all output to stderr for logging | ||
|
||
PAYLOAD=$(mktemp /tmp/resource-in.XXXXXX) | ||
payload=$(cat <&0) | ||
|
||
cat > "$PAYLOAD" <&0 | ||
timestamp=$(jq --raw-output '.version.timestamp // "none"' <<< "${payload}") | ||
|
||
TS=$(jq '.version.timestamp // empty' < "$PAYLOAD") | ||
[ -z "$TS" ] && TS='"none"' | ||
|
||
jq -n "{ | ||
version: { | ||
timestamp: $TS | ||
} | ||
}" >&3 | ||
jq --null-input \ | ||
--arg "timestamp" "${timestamp}" \ | ||
'{ version: { timestamp: $timestamp } }' \ | ||
>&3 |
Oops, something went wrong.