@@ -24,6 +24,7 @@ var extend = require('extend');
2424var util = require ( 'util' ) ;
2525var semver = require ( 'semver' ) ;
2626var _ = require ( 'lodash' ) ;
27+ var metadata = require ( 'gcp-metadata' ) ;
2728
2829var v8debugapi = require ( './v8debugapi.js' ) ;
2930var Debuggee = require ( '../debuggee.js' ) ;
@@ -263,30 +264,31 @@ Debuglet.createDebuggee =
263264 return new Debuggee ( properties ) ;
264265} ;
265266
266- /**
267- * @private
268- */
269- Debuglet . prototype . getProjectId_ = function ( callback ) {
267+ /**
268+ * @private
269+ */
270+ Debuglet . prototype . getProjectId_ = function ( callback ) {
270271 var that = this ;
271272
272273 // We need to figure out whether we are running on GCP. We can use our ability
273274 // to access the metadata service as a test for that.
274275 // TODO: change this to getProjectId in the future.
275- common . utils . getProjectNumber ( function ( err , metadataProject ) {
276- // We should get an error if we are not on GCP.
277- var onGCP = ! err ;
278-
279- // We perfer to use the locally available projectId as that is least
280- // surprising to users.
281- var project = that . debug_ . options . projectId || process . env . GCLOUD_PROJECT ||
282- metadataProject ;
283-
284- // We if don't have a projectId by now, we fail with an error.
285- if ( ! project ) {
286- return callback ( err ) ;
287- }
288- return callback ( null , project , onGCP ) ;
289- } ) ;
276+ metadata . project (
277+ 'numeric-project-id' , function ( err , response , metadataProject ) {
278+ // We should get an error if we are not on GCP.
279+ var onGCP = ! err ;
280+
281+ // We perfer to use the locally available projectId as that is least
282+ // surprising to users.
283+ var project = that . debug_ . options . projectId ||
284+ process . env . GCLOUD_PROJECT || metadataProject ;
285+
286+ // We if don't have a projectId by now, we fail with an error.
287+ if ( ! project ) {
288+ return callback ( err ) ;
289+ }
290+ return callback ( null , project , onGCP ) ;
291+ } ) ;
290292} ;
291293
292294Debuglet . prototype . getSourceContext_ =
0 commit comments