File tree 1 file changed +15
-21
lines changed
1 file changed +15
-21
lines changed Original file line number Diff line number Diff line change 14
14
*/
15
15
16
16
'use strict' ;
17
+
17
18
async function main ( ) {
18
19
// [START container_quickstart]
19
20
const container = require ( '@google-cloud/container' ) ;
20
21
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 ( ) ;
33
24
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
+ } ;
40
32
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 ( ) ;
44
38
// [END container_quickstart]
45
39
}
46
40
You can’t perform that action at this time.
0 commit comments