From 168a475d4294e1111653c64a6bf6e42473ba5753 Mon Sep 17 00:00:00 2001 From: Giacomo Debidda Date: Tue, 13 Sep 2022 18:13:09 +0200 Subject: [PATCH] feat(firestore): init client on Cloud Functions and Cloud Run service --- packages/firestore-utils/src/client.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/firestore-utils/src/client.ts b/packages/firestore-utils/src/client.ts index 47d080f7..c581ba20 100644 --- a/packages/firestore-utils/src/client.ts +++ b/packages/firestore-utils/src/client.ts @@ -37,6 +37,12 @@ export const firestore = (options: Options = DEFAULT_OPTIONS) => { details.push(`process.env.CLOUD_RUN_JOB not set`) } + if (process.env.FUNCTION_SIGNATURE_TYPE) { + return new Firestore() + } else { + details.push(`process.env.FUNCTION_SIGNATURE_TYPE not set`) + } + if (process.env.GOOGLE_APPLICATION_CREDENTIALS) { return new Firestore({ keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS @@ -45,6 +51,12 @@ export const firestore = (options: Options = DEFAULT_OPTIONS) => { details.push(`process.env.GOOGLE_APPLICATION_CREDENTIALS not set`) } + if (process.env.K_SERVICE) { + return new Firestore() + } else { + details.push(`process.env.K_SERVICE not set`) + } + const env_key = options && options.env_key_json_string ? options.env_key_json_string