Skip to content

Commit 1c92077

Browse files
author
Benjamin E. Coe
authored
feat(secrets): begin migration to secret manager from keystore (#587)
1 parent 9c2913e commit 1c92077

4 files changed

Lines changed: 37 additions & 8 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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

synthtool/gcp/templates/node_library/.kokoro/publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /
2424

2525
cd $(dirname $0)/..
2626

27-
NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_{{ publish_token }})
27+
NPM_TOKEN=$(cat $KOKORO_GFILE_DIR/secret_manager/npm_publish_token
2828
echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc
2929
3030
npm install

synthtool/gcp/templates/node_library/.kokoro/release/publish.cfg

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,9 @@ before_action {
4747
}
4848
}
4949

50-
before_action {
51-
fetch_keystore {
52-
keystore_resource {
53-
keystore_config_id: 73713
54-
keyname: "{{ publish_token }}"
55-
}
56-
}
50+
env_vars: {
51+
key: "SECRET_MANAGER_KEYS"
52+
value: "npm_publish_token"
5753
}
5854

5955
# Download trampoline resources.

synthtool/gcp/templates/node_library/.kokoro/trampoline.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ function cleanup() {
2424
}
2525
trap cleanup EXIT
2626

27+
$(dirname $0)/populate-secrets.sh # Secret Manager secrets.
2728
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"

0 commit comments

Comments
 (0)