Skip to content

Commit

Permalink
feat(secrets): begin migration to secret manager from keystore (#70)
Browse files Browse the repository at this point in the history
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/8d5e906d-0de4-4e28-b374-7d5fd4a1ce62/targets

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

Source-Link: googleapis/synthtool@1c92077
  • Loading branch information
yoshi-automation authored Jun 12, 2020
1 parent 20d9978 commit 6513e8c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 12 deletions.
32 changes: 32 additions & 0 deletions .kokoro/populate-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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

# 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"
mkdir -p ${SECRET_LOCATION}
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
do
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"
done
2 changes: 1 addition & 1 deletion .kokoro/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /

cd $(dirname $0)/..

NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-bigquery-storage-npm-token)
NPM_TOKEN=$(cat $KOKORO_GFILE_DIR/secret_manager/npm_publish_token
echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc
npm install
Expand Down
10 changes: 3 additions & 7 deletions .kokoro/release/publish.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ before_action {
}
}

before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "google-cloud-bigquery-storage-npm-token"
}
}
env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "npm_publish_token"
}

# Download trampoline resources.
Expand Down
1 change: 1 addition & 0 deletions .kokoro/trampoline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ function cleanup() {
}
trap cleanup EXIT

$(dirname $0)/populate-secrets.sh # Secret Manager secrets.
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"
2 changes: 1 addition & 1 deletion protos/protos.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots._google_cloud_bigquery_storage_2_0_0_protos || ($protobuf.roots._google_cloud_bigquery_storage_2_0_0_protos = {});
var $root = $protobuf.roots._google_cloud_bigquery_storage_protos || ($protobuf.roots._google_cloud_bigquery_storage_protos = {});

$root.google = (function() {

Expand Down
7 changes: 7 additions & 0 deletions src/v1/big_query_read_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export class BigQueryReadClient {
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;

// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
Expand Down
7 changes: 7 additions & 0 deletions src/v1beta1/big_query_storage_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export class BigQueryStorageClient {
}
opts.servicePath = opts.servicePath || servicePath;
opts.port = opts.port || port;

// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
Expand Down
4 changes: 2 additions & 2 deletions synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-bigquery-storage.git",
"sha": "a83dff661119fc6dc667afffcf984694fe46ee73"
"sha": "20d9978cf09493d982bde1914f4ba1ef6fc21711"
}
},
{
Expand All @@ -19,7 +19,7 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "be74d3e532faa47eb59f1a0eaebde0860d1d8ab4"
"sha": "1c92077459db3dc50741e878f98b08c6261181e0"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "build",
"resolveJsonModule": true,
"lib": [
"es2016",
"es2018",
"dom"
]
},
Expand Down

0 comments on commit 6513e8c

Please sign in to comment.