diff --git a/.env-sample b/.env-sample index c55fd29b..0d1eaa31 100644 --- a/.env-sample +++ b/.env-sample @@ -9,3 +9,6 @@ SLACKBOT_S3_BUCKET=my-bucket SLACKBOT_S3_BUCKET_REGION=us-east-1 AWS_ACCESS_KEY_ID=ABCDEFGHJKL AWS_SECRET_ACCESS_KEY=abcdefghjkl +GOOGLE_CLOUD_BUCKET=my-bucket-name +GOOGLE_CLOUD_PROJECT=my-project-id +GOOGLE_CLOUD_CREDENTIALS_JSON= diff --git a/README.md b/README.md index 5b30f851..0364f185 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,8 @@ There are a couple environment variables that can be used to tweak behavior: ###### Google Cloud Storage +Requires that the Cloud Storage Bucket isn't preventing public access and that `Access Control` is set to `Fine-Grained` and `Object-level ACLs enabled` is set. + - `GOOGLE_CLOUD_BUCKET` (optional) - If you want to use Google Cloud to store visualization images posted by Lookerbot, provide the name of your bucket. If Lookerbot is running on Google Compute Engine, [no further information should be needed if the approprate API scopes are set up](https://github.com/GoogleCloudPlatform/google-cloud-node#on-google-cloud-platform). diff --git a/src/stores/google_cloud_store.ts b/src/stores/google_cloud_store.ts index 8628c636..5a6e2599 100644 --- a/src/stores/google_cloud_store.ts +++ b/src/stores/google_cloud_store.ts @@ -2,7 +2,8 @@ import * as fs from "fs" import { ReadableStreamBuffer } from "stream-buffers" import { Store } from "./store" -const gcs = require("@google-cloud/storage") +// post v2.* nodejs cloud storage client requires the below import +const {Storage} = require("@google-cloud/storage") export class GoogleCloudStore extends Store { @@ -16,9 +17,10 @@ export class GoogleCloudStore extends Store { blobStream.put(buffer) blobStream.stop() - const storage = gcs({ - credentials: process.env.GOOGLE_CLOUD_CREDENTIALS_JSON ? JSON.parse(process.env.GOOGLE_CLOUD_CREDENTIALS_JSON) : undefined, - projectId: process.env.GOOGLE_CLOUD_PROJECT, + // updating due to v2.* nodejs client changes + const storage = new Storage({ + // if keyFilename is supplied, projectID is no longer required + keyFilename: process.env.GOOGLE_CLOUD_CREDENTIALS_JSON }) const bucketName = process.env.GOOGLE_CLOUD_BUCKET