diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh new file mode 100755 index 000000000..85801f403 --- /dev/null +++ b/.kokoro/populate-secrets.sh @@ -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 diff --git a/.kokoro/publish.sh b/.kokoro/publish.sh index b0560f229..24957d71d 100755 --- a/.kokoro/publish.sh +++ b/.kokoro/publish.sh @@ -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-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 diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index a28b328d4..674000017 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -47,13 +47,9 @@ before_action { } } -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google-cloud-storage-npm-token" - } - } +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "npm_publish_token" } # Download trampoline resources. diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh index 9bd4905c4..a4241db23 100755 --- a/.kokoro/trampoline.sh +++ b/.kokoro/trampoline.sh @@ -24,4 +24,5 @@ function cleanup() { } trap cleanup EXIT +$(dirname $0)/populate-secrets.sh # Secret Manager secrets. python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/README.md b/README.md index c6a27c677..38f8750c7 100644 --- a/README.md +++ b/README.md @@ -105,12 +105,14 @@ has instructions for running the samples. | Delete Bucket | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/deleteBucket.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/deleteBucket.js,samples/README.md) | | Delete File | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/deleteFile.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/deleteFile.js,samples/README.md) | | Delete Notification | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/deleteNotification.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/deleteNotification.js,samples/README.md) | +| Disable Bucket Lifecycle Management | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/disableBucketLifecycleManagement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableBucketLifecycleManagement.js,samples/README.md) | | Disable Default Event Based Hold | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/disableDefaultEventBasedHold.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableDefaultEventBasedHold.js,samples/README.md) | | Disable Requester Pays | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/disableRequesterPays.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableRequesterPays.js,samples/README.md) | | Disable Uniform Bucket Level Access | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/disableUniformBucketLevelAccess.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableUniformBucketLevelAccess.js,samples/README.md) | | Download Encrypted File | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/downloadEncryptedFile.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/downloadEncryptedFile.js,samples/README.md) | | Download File | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/downloadFile.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/downloadFile.js,samples/README.md) | | Download File Using Requester Pays | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/downloadFileUsingRequesterPays.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/downloadFileUsingRequesterPays.js,samples/README.md) | +| Enable Bucket Lifecycle Management | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/enableBucketLifecycleManagement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/enableBucketLifecycleManagement.js,samples/README.md) | | Enable Default Event Based Hold | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/enableDefaultEventBasedHold.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/enableDefaultEventBasedHold.js,samples/README.md) | | Enable Default KMS Key | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/enableDefaultKMSKey.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/enableDefaultKMSKey.js,samples/README.md) | | Enable Requester Pays | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/enableRequesterPays.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/enableRequesterPays.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 5cfad334b..4e2a4ee78 100644 --- a/samples/README.md +++ b/samples/README.md @@ -30,12 +30,14 @@ objects to users via direct download. * [Delete Bucket](#delete-bucket) * [Delete File](#delete-file) * [Delete Notification](#delete-notification) + * [Disable Bucket Lifecycle Management](#disable-bucket-lifecycle-management) * [Disable Default Event Based Hold](#disable-default-event-based-hold) * [Disable Requester Pays](#disable-requester-pays) * [Disable Uniform Bucket Level Access](#disable-uniform-bucket-level-access) * [Download Encrypted File](#download-encrypted-file) * [Download File](#download-file) * [Download File Using Requester Pays](#download-file-using-requester-pays) + * [Enable Bucket Lifecycle Management](#enable-bucket-lifecycle-management) * [Enable Default Event Based Hold](#enable-default-event-based-hold) * [Enable Default KMS Key](#enable-default-kms-key) * [Enable Requester Pays](#enable-requester-pays) @@ -310,6 +312,23 @@ __Usage:__ +### Disable Bucket Lifecycle Management + +View the [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/disableBucketLifecycleManagement.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/disableBucketLifecycleManagement.js,samples/README.md) + +__Usage:__ + + +`node samples/disableBucketLifecycleManagement.js` + + +----- + + + + ### Disable Default Event Based Hold View the [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/disableDefaultEventBasedHold.js). @@ -412,6 +431,23 @@ __Usage:__ +### Enable Bucket Lifecycle Management + +View the [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/enableBucketLifecycleManagement.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/enableBucketLifecycleManagement.js,samples/README.md) + +__Usage:__ + + +`node samples/enableBucketLifecycleManagement.js` + + +----- + + + + ### Enable Default Event Based Hold View the [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/enableDefaultEventBasedHold.js). diff --git a/synth.metadata b/synth.metadata index 8cd6b2459..1d3539e1d 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-storage.git", - "sha": "74af32248045a57cdd49addbe269761fbf51b80e" + "sha": "bfbfdfc414aacbdd8e65d1752534e86019ebd6ea" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "be74d3e532faa47eb59f1a0eaebde0860d1d8ab4" + "sha": "1c92077459db3dc50741e878f98b08c6261181e0" } } ]