Skip to content

Commit dde01b2

Browse files
refactor: use repo-metadata to generate readme (#196)
1 parent 30f94ba commit dde01b2

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

container/snippets/quickstart.js

+15-21
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,27 @@
1414
*/
1515

1616
'use strict';
17+
1718
async 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

0 commit comments

Comments
 (0)