@@ -97,18 +97,23 @@ Metadata.getGCEDescriptor = function(projectId) {
9797 * @private
9898 *
9999 * @param {string } projectId - The project ID.
100- * @param {string } clusterName - GKE cluster name .
100+ * @param {function } callback - The callback function .
101101 * @return {object }
102102 */
103- Metadata . getGKEDescriptor = function ( projectId , clusterName ) {
104- return {
105- type : 'container' ,
106- labels : {
107- // TODO(ofrobots): it would be good to include the namespace_id as well.
108- cluster_name : clusterName ,
109- project_id : projectId
103+ Metadata . getGKEDescriptor = function ( projectId , callback ) {
104+ gcpMetadata . instance ( 'attributes/clusterName' , function ( err , _ , clusterName ) {
105+ if ( err ) {
106+ return callback ( err ) ;
110107 }
111- } ;
108+ callback ( null , {
109+ type : 'container' ,
110+ labels : {
111+ // TODO(ofrobots): it would be good to include the namespace_id as well.
112+ cluster_name : clusterName ,
113+ project_id : projectId
114+ }
115+ } )
116+ } ) ;
112117} ;
113118
114119/**
@@ -144,13 +149,7 @@ Metadata.prototype.getDefaultResource = function(callback) {
144149
145150 self . logging . auth . getEnvironment ( function ( err , env ) {
146151 if ( env . IS_CONTAINER_ENGINE ) {
147- gcpMetadata . instance ( 'attributes/clusterName' ,
148- function ( err , _ , clusterName ) {
149- if ( err ) {
150- return callback ( err ) ;
151- }
152- callback ( null , Metadata . getGKEDescriptor ( projectId , clusterName ) ) ;
153- } ) ;
152+ Metadata . getGKEDescriptor ( projectId , callback ) ;
154153 } else {
155154 var defaultResource ;
156155
0 commit comments