29 lines
629 B
Text
29 lines
629 B
Text
|
#!/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 "$@"
|