Compare commits
5 Commits
19fd9f4d83
...
bf5f01a870
| Author | SHA1 | Date | |
|---|---|---|---|
|
bf5f01a870
|
|||
|
707909578a
|
|||
|
7830df45e4
|
|||
|
f4136c476d
|
|||
|
05555a47c7
|
14
dist/scripts/src/fetch-secrets.sh
vendored
14
dist/scripts/src/fetch-secrets.sh
vendored
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
fetch_secret() {
|
||||
local target_secret="${1:?Target secret local_secret is required}"
|
||||
local env="${2:?Environment is required}"
|
||||
@@ -46,16 +48,22 @@ main() {
|
||||
env="$(jq -r .env <<<"${obj}")"
|
||||
filename="$(jq -r .filename <<<"${obj}")"
|
||||
|
||||
if [[ ${local_secret} == "null" || ${target_secret} == "null" ]]; then
|
||||
printf "Error: Missing required fields in entry: %s\n" "${obj}" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
# Default output file name
|
||||
output_file="${secrets_dir}/${output_file}"
|
||||
output_file="${secrets_dir}/${local_secret}"
|
||||
|
||||
# If filename is specified in json, use it; otherwise, use the local_secret as the filename
|
||||
if [[ -n ${filename} && ${filename} != "null" ]]; then
|
||||
output_file="${secrets_dir}/${filename}"
|
||||
fi
|
||||
|
||||
if [[ -z ${env} ]]; then
|
||||
printf "Warning: Environment not specified for secret %s, assuming 'prod'\n" "${local_secret}" >&2
|
||||
if [[ ${env} == "null" ]]; then
|
||||
printf "Warning: Environment not specified for secret %s, assuming 'dev'\n" "${local_secret}" >&2
|
||||
env="dev"
|
||||
fi
|
||||
|
||||
printf "Processing %s -> %s (%s)\n" "${local_secret}" "${target_secret}" "${env}"
|
||||
|
||||
Reference in New Issue
Block a user