From c78384f93ba594ccce836b0b795a004afb75fe40 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Fri, 26 May 2023 23:20:20 +0200 Subject: [PATCH] improve dummy check and in scripts --- check | 20 +++++++++++++++++--- in | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/check b/check index 70aa535..d1390bb 100755 --- a/check +++ b/check @@ -1,6 +1,20 @@ #!/bin/sh -exec 3>&1 -exec 1>&2 +set -e -echo "[]" >&3 +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) + +cat > "$PAYLOAD" <&0 + +TS=$(jq '.version.timestamp // empty' < "$PAYLOAD") + +if [ -z "$TS" ]; then + echo '[]' >&3 +else + jq -n "[ + { timestamp: $TS } + ]" >&3 +fi diff --git a/in b/in index 1a24852..533c0ea 100755 --- a/in +++ b/in @@ -1 +1,19 @@ #!/bin/sh + +set -e + +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) + +cat > "$PAYLOAD" <&0 + +TS=$(jq '.version.timestamp // empty' < "$PAYLOAD") +[ -z "$TS" ] && TS='"none"' + +jq -n "{ + version: { + timestamp: $TS + } +}" >&3