#!/bin/bash

set -e
set -u
set -o pipefail

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

eval "$(jq -r '@sh "PUBLIC_KEY=\(.public_key)"')"

if [[ -f $PUBLIC_KEY ]]; then
    jq -c -n --arg public_key "$(cat ${PUBLIC_KEY})" '{ "public_key": $public_key }'
else
    echo '{ "public_key": "" }'
fi

#!/bin/bash

set -e
set -u
set -o pipefail

print_public_key() {
    local key=$1

    if [[ -n "$key" ]]; then
        jq -c -n --arg public_key "$key" '{ "public_key": $public_key }'
    else
        echo '{"public_key":""}'
    fi
}

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

PUBLIC_KEY=${PUBLIC_KEY-}
eval "$(jq -r '@sh "PUBLIC_KEY=\(.public_key)"')"

if [[ -f $PUBLIC_KEY ]]; then
    print_public_key "$(cat ${PUBLIC_KEY})"
else
    print_public_key "$(echo ${PUBLIC_KEY})"
fi

Support SSH key passed as a variable.
Support SSH key passed as a variable.

Signed-off-by: Krzysztof Wilczynski <5f1c0be89013f8fde969a8dcb2fa1d522e94ee00@linux.com>
