Skip to content

Commit

Permalink
chore: use gcloud config-helper to get projectId (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored and ofrobots committed Jan 8, 2018
1 parent af01878 commit b3bda6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/test.googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
};
Expand Down

0 comments on commit b3bda6b

Please sign in to comment.