@meistrari/mise-en-place 2.18.2 → 2.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,20 +26,34 @@ if [ -z "$FILE_NAME" ]; then
|
|
|
26
26
|
exit 1
|
|
27
27
|
fi
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
# Maybe in the future we can make this script more flexible and allow the user
|
|
30
|
+
# to specify the environment as an argument or environment variable.
|
|
31
|
+
# For now, we will hardcode it to development.
|
|
32
|
+
ENV=development
|
|
33
|
+
|
|
34
|
+
# Reads a secret from the kv mount and appends its values to $FILE_NAME.
|
|
35
|
+
# Aborts the script if the secret cannot be read.
|
|
36
|
+
append_secrets() {
|
|
37
|
+
local secret_path="$1"
|
|
38
|
+
local secret_json
|
|
39
|
+
|
|
40
|
+
if ! secret_json="$(vault kv get -mount=kv -format=json "$secret_path" 2>&1)"; then
|
|
41
|
+
echo "Failed to read kv/$secret_path from $VAULT_ADDR:" >&2
|
|
42
|
+
echo "$secret_json" >&2
|
|
43
|
+
echo "" >&2
|
|
44
|
+
echo "Inspect it in the browser: $VAULT_ADDR/ui/vault/secrets/kv/kv/list/$(dirname "$secret_path")/" >&2
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
echo "$secret_json" | jq -r '.data.data | to_entries[] | "\(.key)=\(.value | @sh)"' >> "$FILE_NAME"
|
|
49
|
+
}
|
|
40
50
|
|
|
41
51
|
echo "# Values from VaultSecrets" > "$FILE_NAME"
|
|
42
52
|
echo "# Edits to this file may be overwritten" >> "$FILE_NAME"
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
# Shared values come first so app-specific ones override them on collision.
|
|
55
|
+
if [ "$ENV" == "development" ]; then
|
|
56
|
+
append_secrets "shared/$ENV"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
append_secrets "$APP_NAME/$ENV/$WORKLOAD_PATH"
|