Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
fix: proper fallback option handling (#74)
Browse files Browse the repository at this point in the history
* changes without context

        autosynth cannot find the source of changes triggered by earlier changes in this
        repository, or by version upgrades to tools such as linters.

* feat(secrets): begin migration to secret manager from keystore

Source-Author: Benjamin E. Coe <bencoe@google.com>
Source-Date: Mon Jun 8 09:51:11 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 1c92077459db3dc50741e878f98b08c6261181e0
Source-Link: googleapis/synthtool@1c92077

* chore(nodejs_templates): add script logging to node_library populate-secrets.sh

Co-authored-by: Benjamin E. Coe <bencoe@google.com>

Source-Author: BenWhitehead <BenWhitehead@users.noreply.github.com>
Source-Date: Wed Jun 10 22:24:28 2020 -0400
Source-Repo: googleapis/synthtool
Source-Sha: e7034945fbdc0e79d3c57f6e299e5c90b0f11469
Source-Link: googleapis/synthtool@e703494
  • Loading branch information
yoshi-automation authored Jun 15, 2020
1 parent e1d1b17 commit 75a2648
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 42 deletions.
44 changes: 44 additions & 0 deletions .kokoro/populate-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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 \
--credential-file-override=${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json \
--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
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-game-servers-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-game-servers-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"
13 changes: 5 additions & 8 deletions src/v1beta/game_server_clusters_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ export class GameServerClustersServiceClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the GameServerClustersServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
13 changes: 5 additions & 8 deletions src/v1beta/game_server_configs_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,11 @@ export class GameServerConfigsServiceClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the GameServerConfigsServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
13 changes: 5 additions & 8 deletions src/v1beta/game_server_deployments_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ export class GameServerDeploymentsServiceClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the GameServerDeploymentsServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
13 changes: 5 additions & 8 deletions src/v1beta/realms_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,11 @@ export class RealmsServiceClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the RealmsServiceClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
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-game-servers.git",
"sha": "f72d636da39868449f3abdf8371beaceb693f7d0"
"sha": "e1d1b17aa79de4b0f34689ce83a1796ebe2508ed"
}
},
{
Expand All @@ -19,7 +19,7 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "be74d3e532faa47eb59f1a0eaebde0860d1d8ab4"
"sha": "e7034945fbdc0e79d3c57f6e299e5c90b0f11469"
}
}
],
Expand Down

0 comments on commit 75a2648

Please sign in to comment.