Skip to content

Commit e703494

Browse files
BenWhiteheadBenjamin E. Coe
andauthored
chore(nodejs_templates): add script logging to node_library populate-secrets.sh (#618)
Co-authored-by: Benjamin E. Coe <[email protected]>
1 parent fc0fce9 commit e703494

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

synthtool/gcp/templates/node_library/.kokoro/populate-secrets.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@
1515

1616
set -eo pipefail
1717

18+
function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
19+
function msg { println "$*" >&2 ;}
20+
function println { printf '%s\n' "$(now) $*" ;}
21+
22+
1823
# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
1924
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
2025
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
26+
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
2127
mkdir -p ${SECRET_LOCATION}
2228
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
2329
do
30+
msg "Retrieving secret ${key}"
2431
docker run --entrypoint=gcloud \
2532
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
2633
gcr.io/google.com/cloudsdktool/cloud-sdk \
@@ -29,4 +36,9 @@ do
2936
--project cloud-devrel-kokoro-resources \
3037
--secret $key > \
3138
"$SECRET_LOCATION/$key"
39+
if [[ $? == 0 ]]; then
40+
msg "Secret written to ${SECRET_LOCATION}/${key}"
41+
else
42+
msg "Error retrieving secret ${key}"
43+
fi
3244
done

0 commit comments

Comments
 (0)