Skip to content

Commit

Permalink
chore(nodejs_templates): add script logging to node_library populate-…
Browse files Browse the repository at this point in the history
…secrets.sh (#12)

This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/e306327b-605f-4c07-9420-c106e40c47d5/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@e703494
  • Loading branch information
yoshi-automation authored Jun 11, 2020
1 parent c2281ce commit e386676
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .kokoro/populate-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@

set -eo pipefail

function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
function msg { println "$*" >&2 ;}
function println { printf '%s\n' "$(now) $*" ;}


# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
mkdir -p ${SECRET_LOCATION}
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
do
msg "Retrieving secret ${key}"
docker run --entrypoint=gcloud \
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
gcr.io/google.com/cloudsdktool/cloud-sdk \
Expand All @@ -29,4 +36,9 @@ do
--project cloud-devrel-kokoro-resources \
--secret $key > \
"$SECRET_LOCATION/$key"
if [[ $? == 0 ]]; then
msg "Secret written to ${SECRET_LOCATION}/${key}"
else
msg "Error retrieving secret ${key}"
fi
done
4 changes: 2 additions & 2 deletions synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-local-auth.git",
"sha": "aeb1f0761a55194a8842dd1e72de15b9db668d27"
"sha": "756a52962e82cd68cc637249552dfa63f5d20941"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "1c92077459db3dc50741e878f98b08c6261181e0"
"sha": "e7034945fbdc0e79d3c57f6e299e5c90b0f11469"
}
}
]
Expand Down

0 comments on commit e386676

Please sign in to comment.