From ac25a0f5770ca577e6f9d324171a47e2a62c5e99 Mon Sep 17 00:00:00 2001 From: Jeremy Guarini Date: Fri, 25 Feb 2022 13:48:07 -0800 Subject: [PATCH] When using GCS for the techdocs storage and not setting the GOOGLE_APPLICATION_CREDENTIALS environment variable, authentication and accessing the bucket fails due to the project ID not being found. Relevant log output ``` techdocs error from GCS client library: Unable to detect a Project Id in the current environment. ``` By adding the projectID when initializing the Storage client, this should fix the issue. This current approach expects the project_id to be in the json credentials, which it usually is. Another option would be to re-add the app-config projectID value back and allow users to specify the projectID that way as well. Signed-off-by: Jeremy Guarini --- packages/techdocs-common/src/stages/publish/googleStorage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/techdocs-common/src/stages/publish/googleStorage.ts b/packages/techdocs-common/src/stages/publish/googleStorage.ts index f072412c20..45ecb32cf7 100644 --- a/packages/techdocs-common/src/stages/publish/googleStorage.ts +++ b/packages/techdocs-common/src/stages/publish/googleStorage.ts @@ -82,7 +82,7 @@ export class GoogleGCSPublish implements PublisherBase { const credentials = config.getOptionalString( 'techdocs.publisher.googleGcs.credentials', ); - let credentialsJson = {}; + let credentialsJson: any = {}; if (credentials) { try { credentialsJson = JSON.parse(credentials); @@ -95,6 +95,7 @@ export class GoogleGCSPublish implements PublisherBase { const storageClient = new Storage({ ...(credentials && { + projectId: credentialsJson.project_id, credentials: credentialsJson, }), });