forked from jkroepke/helm-secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvault.sh
32 lines (25 loc) · 812 Bytes
/
vault.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env sh
# shellcheck disable=SC2034
_DRIVER_REGEX='!vault [A-z0-9][A-z0-9/\-]*\#[A-z0-9][A-z0-9-]*'
# shellcheck source=scripts/drivers/_custom.sh
. "${SCRIPT_DIR}/drivers/_custom.sh"
_custom_driver_get_secret() {
_type=$1
_SECRET_PATH="${2%#*}"
_SECRET_FIELD="${2#*#}"
if [ "${_type}" != "yaml" ]; then
echo "Only decryption of yaml files are allowed!"
exit 1
fi
if ! vault kv get -format="${_type}" -field="${_SECRET_FIELD}" "${_SECRET_PATH}"; then
echo "Error while get secret from vault!" >&2
echo vault kv get -format="${_type}" -field="${_SECRET_FIELD}" "${_SECRET_PATH}" >&2
exit 1
fi
}
_custom_driver_is_yaml() {
_type=$1
_SECRET_PATH="${2%#*}"
_SECRET_FIELD="${2#*#}"
[ "${_SECRET_FIELD}" = "data" ]
}