Loading scripts/vault-read.sh +7 −4 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ fi path=$1 # Get the kv sec from path in json j=$(vault kv get -format=json $path) j=$(vault kv get -format=json "$path") return_code=$? if [ "$return_code" -ne "0" ]; then Loading @@ -21,12 +21,15 @@ if [ "$return_code" -ne "0" ]; then fi f=$(echo "$j" | jq -r '.data.format//.data.data.format' 2> /dev/null) v=$(echo "$j" | jq -r '.data.value//.data.data.value') # jq -j adds no trailing newline; the trailing-x sentinel preserves # any newlines in the value that $(...) would otherwise strip. v=$(echo "$j" | jq -j '.data.value//.data.data.value'; printf x) v=${v%x} # if value format is base64, decode it if [ "base64" == "$f" ] then echo -n "$v" | base64 --decode printf '%s' "$v" | base64 --decode else echo -n "$v" printf '%s' "$v" fi Loading
scripts/vault-read.sh +7 −4 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ fi path=$1 # Get the kv sec from path in json j=$(vault kv get -format=json $path) j=$(vault kv get -format=json "$path") return_code=$? if [ "$return_code" -ne "0" ]; then Loading @@ -21,12 +21,15 @@ if [ "$return_code" -ne "0" ]; then fi f=$(echo "$j" | jq -r '.data.format//.data.data.format' 2> /dev/null) v=$(echo "$j" | jq -r '.data.value//.data.data.value') # jq -j adds no trailing newline; the trailing-x sentinel preserves # any newlines in the value that $(...) would otherwise strip. v=$(echo "$j" | jq -j '.data.value//.data.data.value'; printf x) v=${v%x} # if value format is base64, decode it if [ "base64" == "$f" ] then echo -n "$v" | base64 --decode printf '%s' "$v" | base64 --decode else echo -n "$v" printf '%s' "$v" fi