From a4a85e9317eb900fded07bb405f53bf928c8a68c Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Tue, 28 Nov 2017 09:31:28 -0800 Subject: [PATCH] chore: use gcloud config-helper to get projectId (#194) --- src/auth/googleauth.ts | 4 ++-- test/test.googleauth.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/auth/googleauth.ts b/src/auth/googleauth.ts index 5a3fb94f..ae60ffc5 100644 --- a/src/auth/googleauth.ts +++ b/src/auth/googleauth.ts @@ -171,7 +171,7 @@ export class GoogleAuth { // TODO: make this a proper async function return new Promise((resolve, reject) => { exec( - 'gcloud -q config list core/project --format=json', + 'gcloud config config-helper --format json', (err, stdout, stderr) => { if (err) { reject(err); @@ -537,7 +537,7 @@ export class GoogleAuth { try { const r = await this._getSDKDefaultProjectId(); if (r.stdout) { - return JSON.parse(r.stdout).core.project; + return JSON.parse(r.stdout).configuration.properties.core.project; } } catch (e) { // Ignore any errors diff --git a/test/test.googleauth.ts b/test/test.googleauth.ts index eb83096f..f3eb2135 100644 --- a/test/test.googleauth.ts +++ b/test/test.googleauth.ts @@ -963,7 +963,9 @@ describe('GoogleAuth', () => { blockGoogleApplicationCredentialEnvironmentVariable(auth); auth._getSDKDefaultProjectId = () => { return Promise.resolve({ - stdout: JSON.stringify({core: {project: fixedProjectId}}), + stdout: JSON.stringify({ + configuration: {properties: {core: {project: fixedProjectId}}} + }), stderr: null }); };