File tree Expand file tree Collapse file tree 1 file changed +15
-21
lines changed
Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Original file line number Diff line number Diff line change 1414 */
1515
1616'use strict' ;
17+
1718async function main ( ) {
1819 // [START container_quickstart]
1920 const container = require ( '@google-cloud/container' ) ;
2021
21- if (
22- ! process . env . GCLOUD_PROJECT ||
23- ! process . env . GOOGLE_APPLICATION_CREDENTIALS
24- ) {
25- throw new Error (
26- 'Usage: GCLOUD_PROJECT=<project_id> GOOGLE_APPLICATION_CREDENTIALS=<path to key json file> node #{$0}'
27- ) ;
28- }
29-
30- const client = new container . v1 . ClusterManagerClient ( {
31- // optional auth parameters.
32- } ) ;
22+ // Create the Cluster Manager Client
23+ const client = new container . v1 . ClusterManagerClient ( ) ;
3324
34- const projectId = process . env . GCLOUD_PROJECT ;
35- const zone = 'us-central1-a' ;
36- const request = {
37- projectId : projectId ,
38- zone : zone ,
39- } ;
25+ async function quickstart ( ) {
26+ const zone = 'us-central1-a' ;
27+ const projectId = await client . getProjectId ( ) ;
28+ const request = {
29+ projectId : projectId ,
30+ zone : zone ,
31+ } ;
4032
41- const [ response ] = await client . listClusters ( request ) ;
42- console . log ( 'Clusters:' ) ;
43- console . log ( response ) ;
33+ const [ response ] = await client . listClusters ( request ) ;
34+ console . log ( 'Clusters:' ) ;
35+ console . log ( response ) ;
36+ }
37+ quickstart ( ) ;
4438 // [END container_quickstart]
4539}
4640
You can’t perform that action at this time.
0 commit comments