Skip to content

Commit

Permalink
feat: added cli functionality to dataproc quickstart sample (#291)
Browse files Browse the repository at this point in the history
* Added/exposed CLI functionality for dataproc quickstart

Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
bradmiro and bcoe authored Feb 4, 2020
1 parent 728bc54 commit e5b8974
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions dataproc/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// [START dataproc_quickstart]
// This quickstart sample walks a user through creating a Cloud Dataproc
// cluster, submitting a PySpark job from Google Cloud Storage to the
// cluster, reading the output of the job and deleting the cluster, all
// using the Node.js client library.
//
// Usage:
// node quickstart.js <PROJECT_ID> <REGION> <CLUSTER_NAME> <GCS_JOB_FILE_PATH>

'use strict';

function main(projectId, region, clusterName, jobFilePath) {
// [START dataproc_quickstart]
const dataproc = require('@google-cloud/dataproc').v1;
const {Storage} = require('@google-cloud/storage');

Expand All @@ -32,12 +40,6 @@ function main(projectId, region, clusterName, jobFilePath) {
});

async function quickstart() {
// TODO(developer): Uncomment and set the following variables
// projectId = 'YOUR_PROJECT_ID'
// region = 'YOUR_CLUSTER_REGION'
// clusterName = 'YOUR_CLUSTER_NAME'
// jobFilePath = 'YOUR_JOB_FILE_PATH'

// Create the cluster config
const cluster = {
projectId: projectId,
Expand Down Expand Up @@ -142,7 +144,16 @@ function main(projectId, region, clusterName, jobFilePath) {
}

quickstart();
// [END dataproc_quickstart]
}

main(...process.argv.slice(2));
const args = process.argv.slice(2);

if (args.length !== 4) {
console.log(
'Insufficient number of parameters provided. Please make sure a ' +
'PROJECT_ID, REGION, CLUSTER_NAME and JOB_FILE_PATH are provided, in this order.'
);
}

main(...args);
// [END dataproc_quickstart]

0 comments on commit e5b8974

Please sign in to comment.