-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add CI secrets manager (via synth) (#271)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/5da1d2aa-a963-44d1-952a-3ed428de6719/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@27f4406 Source-Link: googleapis/synthtool@dba48bb Source-Link: googleapis/synthtool@257fda1 Source-Link: googleapis/synthtool@ffcee79 Source-Link: googleapis/synthtool@d302f93
- Loading branch information
1 parent
c75e9cd
commit fe54cb7
Showing
6 changed files
with
86 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
# Copyright 2020 Google LLC. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
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 \ | ||
secrets versions access latest \ | ||
--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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters