|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2020 Google LLC. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -eo pipefail |
| 17 | + |
| 18 | +# Populates requested secrets set in SECRET_MANAGER_KEYS from service account: |
| 19 | +# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com |
| 20 | +SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" |
| 21 | +mkdir -p ${SECRET_LOCATION} |
| 22 | +for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") |
| 23 | +do |
| 24 | + docker run --entrypoint=gcloud \ |
| 25 | + --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ |
| 26 | + gcr.io/google.com/cloudsdktool/cloud-sdk \ |
| 27 | + secrets versions access latest \ |
| 28 | + --credential-file-override=${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json \ |
| 29 | + --project cloud-devrel-kokoro-resources \ |
| 30 | + --secret $key > \ |
| 31 | + "$SECRET_LOCATION/$key" |
| 32 | +done |
0 commit comments