@meistrari/mise-en-place 2.18.3 → 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
+ # 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.
29
32
  ENV=development
30
33
 
31
- SECRET_PATH="$APP_NAME/$ENV/$WORKLOAD_PATH"
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
32
39
 
33
- if ! SECRET_JSON="$(vault kv get -mount=kv -format=json "$SECRET_PATH" 2>&1)"; then
34
- echo "Failed to read kv/$SECRET_PATH from $VAULT_ADDR:" >&2
35
- echo "$SECRET_JSON" >&2
36
- echo "" >&2
37
- echo "Inspect it in the browser: $VAULT_ADDR/ui/vault/secrets/kv/kv/list/${APP_NAME}/" >&2
38
- exit 1
39
- fi
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
- echo "$SECRET_JSON" \
45
- | jq -r '.data.data | to_entries[] | "\(.key)=\(.value | @sh)"' >> "$FILE_NAME"
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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/mise-en-place",
3
- "version": "2.18.3",
3
+ "version": "2.18.4",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",