diff --git a/container/snippets/quickstart.js b/container/snippets/quickstart.js index 1e8218e282..1cb292b7f6 100644 --- a/container/snippets/quickstart.js +++ b/container/snippets/quickstart.js @@ -14,37 +14,33 @@ */ 'use strict'; +async function main() { + // [START container_quickstart] + const container = require('@google-cloud/container'); -// [START container_quickstart] -const container = require('@google-cloud/container'); + if ( + !process.env.GCLOUD_PROJECT || + !process.env.GOOGLE_APPLICATION_CREDENTIALS + ) { + throw new Error( + 'Usage: GCLOUD_PROJECT= GOOGLE_APPLICATION_CREDENTIALS= node #{$0}' + ); + } -if ( - !process.env.GCLOUD_PROJECT || - !process.env.GOOGLE_APPLICATION_CREDENTIALS -) { - throw new Error( - 'Usage: GCLOUD_PROJECT= GOOGLE_APPLICATION_CREDENTIALS= node #{$0}' - ); -} + const client = new container.v1.ClusterManagerClient({ + // optional auth parameters. + }); -const client = new container.v1.ClusterManagerClient({ - // optional auth parameters. -}); + const projectId = process.env.GCLOUD_PROJECT; + const zone = 'us-central1-a'; + const request = { + projectId: projectId, + zone: zone, + }; -const projectId = process.env.GCLOUD_PROJECT; -const zone = 'us-central1-a'; -const request = { - projectId: projectId, - zone: zone, -}; + const [response] = await client.listClusters(request); + console.log(response); + // [END container_quickstart] +} -client - .listClusters(request) - .then(responses => { - const response = responses[0]; - console.log(response); - }) - .catch(err => { - console.error('ERROR:', err); - }); -// [END container_quickstart] +main().catch(console.error);