cfg/bin/git-credential-vault
2023-08-25 17:44:14 +02:00

28 lines
629 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
source "${HOME}/bin/script_framework.sh"
function handle_get() {
while read line; do
local param=$(cut -d '=' -f 1 <<<"${line}")
local value=$(cut -d '=' -f 2- <<<"${line}")
[[ $param == host ]] || continue
vault read -format=json secret/git-credential/${value} 2>/dev/null | jq -r '.data | to_entries[] | [.key, .value] | join("=")' || return 1
info "[git-credential-vault] Read credential for '${value}' from Vault"
done
}
function main() {
local action="${1:-_invalid}"
shift
case ${action} in
get) handle_get ;;
*) return 1 ;;
esac
}
main "$@"