From dde01b212b2f9bbbd1d8dba75e46e6d8c3a74127 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Tue, 21 May 2019 01:25:54 +0000 Subject: [PATCH] refactor: use repo-metadata to generate readme (#196) --- container/snippets/quickstart.js | 36 +++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/container/snippets/quickstart.js b/container/snippets/quickstart.js index 36e995f4a2..4fb11a1f97 100644 --- a/container/snippets/quickstart.js +++ b/container/snippets/quickstart.js @@ -14,33 +14,27 @@ */ 'use strict'; + async function main() { // [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}' - ); - } - - const client = new container.v1.ClusterManagerClient({ - // optional auth parameters. - }); + // Create the Cluster Manager Client + const client = new container.v1.ClusterManagerClient(); - const projectId = process.env.GCLOUD_PROJECT; - const zone = 'us-central1-a'; - const request = { - projectId: projectId, - zone: zone, - }; + async function quickstart() { + const zone = 'us-central1-a'; + const projectId = await client.getProjectId(); + const request = { + projectId: projectId, + zone: zone, + }; - const [response] = await client.listClusters(request); - console.log('Clusters:'); - console.log(response); + const [response] = await client.listClusters(request); + console.log('Clusters:'); + console.log(response); + } + quickstart(); // [END container_quickstart] }