1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/fixtures/auth/docker-credential-shell-test
Tianon Gravi 52379fa76d Convert script shebangs from "#!/bin/bash" to "#!/usr/bin/env bash"
This is especially important for distributions like NixOS where `/bin/bash` doesn't exist, or for MacOS users who've installed a newer version of Bash than the one that comes with their OS.

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
2017-02-13 11:01:54 -08:00

55 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
listFile=shell_test_list.json
case $1 in
"store")
in=$(</dev/stdin)
server=$(echo "$in" | jq --raw-output ".ServerURL")
serverHash=$(echo "$server" | sha1sum - | awk '{print $1}')
username=$(echo "$in" | jq --raw-output ".Username")
password=$(echo "$in" | jq --raw-output ".Secret")
echo "{ \"Username\": \"${username}\", \"Secret\": \"${password}\" }" > $TEMP/$serverHash
# add the server to the list file
if [[ ! -f $TEMP/$listFile ]]; then
echo "{ \"${server}\": \"${username}\" }" > $TEMP/$listFile
else
list=$(<$TEMP/$listFile)
echo "$list" | jq ". + {\"${server}\": \"${username}\"}" > $TEMP/$listFile
fi
;;
"get")
in=$(</dev/stdin)
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
if [[ ! -f $TEMP/$serverHash ]]; then
echo "credentials not found in native keychain"
exit 1
fi
payload=$(<$TEMP/$serverHash)
echo "$payload"
;;
"erase")
in=$(</dev/stdin)
serverHash=$(echo "$in" | sha1sum - | awk '{print $1}')
rm -f $TEMP/$serverHash
# Remove the server from the list
list=$(<$TEMP/$listFile)
echo "$list" | jq "del(.[\"${in}\"])" > $TEMP/$listFile
;;
"list")
if [[ ! -f $TEMP/$listFile ]]; then
echo "{}"
else
payload=$(<$TEMP/$listFile)
echo "$payload"
fi
;;
*)
echo "unknown credential option"
exit 1
;;
esac