Skip to content

Commit

Permalink
chore: update sa for loading secrets (googleapis#8729)
Browse files Browse the repository at this point in the history
  • Loading branch information
codyoss authored Oct 16, 2023
1 parent fe554b5 commit 6cc6d70
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/kokoro/populate-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@

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) $*" ;}

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
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 \
secrets versions access latest \
--credential-file-override=${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json \
--project cloud-devrel-kokoro-resources \
--secret ${key} > \
"${SECRET_LOCATION}/${key}"
Expand Down

0 comments on commit 6cc6d70

Please sign in to comment.