forked from jkroepke/helm-secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvals.sh
58 lines (47 loc) · 1.15 KB
/
vals.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env sh
_VALS="${HELM_SECRETS_VALS_PATH:-vals}"
_vals() {
stdin=$(cat /dev/stdin)
# shellcheck disable=SC2086
set -- ${SECRET_BACKEND_ARGS} "$@"
# In case of an error, give us stderr
# https://github.com/variantdev/vals/issues/60
if ! printf '%s' "$stdin" | $_VALS "$@" 2>/dev/null; then
log 'vals error:'
printf '%s' "$stdin" | $_VALS "$@" >/dev/null
fi
}
backend_is_file_encrypted() {
input="${1}"
grep -q 'ref+' "${input}"
}
backend_encrypt_file() {
echo "Encrypting files is not supported!"
exit 1
}
backend_decrypt_file() {
type="${1}"
input="${2}"
# if omit then output to stdout
output="${3:-}"
if [ "${type}" = "auto" ]; then
type=$(_vals_get_type "${input}")
fi
if [ "${output}" != "" ]; then
_vals eval -o "${type}" <"${input}" >"${output}"
else
_vals eval -o "${type}" <"${input}"
fi
}
backend_edit_file() {
echo "Editing files is not supported!"
exit 1
}
_vals_get_type() {
file_type=$(_file_get_extension "${1}")
if [ "${file_type}" = "json" ]; then
echo "json"
else
echo "yaml"
fi
}