From b68c784cacda00cf8d807039e28fb2f18f3e2263 Mon Sep 17 00:00:00 2001 From: Chyroc Chen Date: Tue, 10 Jan 2017 14:42:31 +0800 Subject: [PATCH] code style and use === not == --- index.js | 74 +++++++++++++++++----------------- src/connecttor/get.js | 20 ++++----- src/connecttor/setOptions.js | 4 +- src/driver/get.js | 10 ++--- src/driver/setOptions.js | 2 +- src/job/create.js | 8 ++-- src/job/delete.js | 10 ++--- src/job/get.js | 30 +++++++------- src/job/setOptions.js | 22 +++++----- src/job/update.js | 28 ++++++------- src/link/create.js | 12 +++--- src/link/delete.js | 10 ++--- src/link/get.js | 30 +++++++------- src/link/setOptions.js | 42 +++++++++---------- src/link/update.js | 22 +++++----- src/submission/get.js | 10 ++--- src/submission/setOptions.js | 2 +- src/submission/status.js | 36 ++++++++--------- src/utils/getVersion.js | 10 ++--- src/utils/setRequestOptions.js | 14 +++---- 20 files changed, 198 insertions(+), 198 deletions(-) diff --git a/index.js b/index.js index adf4d2e..cd4ac1c 100644 --- a/index.js +++ b/index.js @@ -26,47 +26,47 @@ import {getSubmissionALL, getSubmissionByJobName} from './src/submission/get' import {startJob, stopJob, getJobStatus} from './src/submission/status' export { - // version - getVersion, + // version + getVersion, - // authorization - createRole, - deleteRole, - getRole, + // authorization + createRole, + deleteRole, + getRole, - // connecttor - getConnectorAll, - getConnectorByConnectorName, + // connecttor + getConnectorAll, + getConnectorByConnectorName, - // driver - getDriverAll, + // driver + getDriverAll, - // job - createJob, - deleteJob, - deleteJobAll, - getJobAll, - getJobByConnectorName, - getJobByJobName, - updateJob, - updateJobEnable, - updateJobDisable, + // job + createJob, + deleteJob, + deleteJobAll, + getJobAll, + getJobByConnectorName, + getJobByJobName, + updateJob, + updateJobEnable, + updateJobDisable, - // link - createLink, - deleteLink, - deleteLinkAll, - getLinkAll, - getLinkByConnectorName, - getLinkByLinkName, - updateLink, - updateEnable, - updateDisable, + // link + createLink, + deleteLink, + deleteLinkAll, + getLinkAll, + getLinkByConnectorName, + getLinkByLinkName, + updateLink, + updateEnable, + updateDisable, - // submission - getSubmissionALL, - getSubmissionByJobName, - startJob, - stopJob, - getJobStatus + // submission + getSubmissionALL, + getSubmissionByJobName, + startJob, + stopJob, + getJobStatus } diff --git a/src/connecttor/get.js b/src/connecttor/get.js index 5ee1d6a..2dca6e6 100644 --- a/src/connecttor/get.js +++ b/src/connecttor/get.js @@ -9,18 +9,18 @@ import {setGetConnectorOptions} from './setOptions' export function getConnectorAll () { const options = setGetConnectorOptions('all') return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export function getConnectorByConnectorName (connectorName) { const options = setGetConnectorOptions('subName', connectorName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } diff --git a/src/connecttor/setOptions.js b/src/connecttor/setOptions.js index 0959070..8a636ad 100644 --- a/src/connecttor/setOptions.js +++ b/src/connecttor/setOptions.js @@ -5,9 +5,9 @@ import {setGetOptions} from '../utils/setRequestOptions' export function setGetConnectorOptions (tag = 'all', connectorName = null) { - if (tag == 'all') { + if (tag === 'all') { return setGetOptions(tag, 'v1/connector') - } else if (tag == 'subName') { + } else if (tag === 'subName') { return setGetOptions(tag, 'v1/connector', connectorName) } } diff --git a/src/driver/get.js b/src/driver/get.js index fc5c1a1..699001d 100644 --- a/src/driver/get.js +++ b/src/driver/get.js @@ -9,9 +9,9 @@ const r = require('request-promise') export function getDriverAll () { const options = setGetJobOptions('all') return r(options) - .then(function (repos) { - return repos['links'] - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos['links'] + }) + .catch(function (err) { + }) } diff --git a/src/driver/setOptions.js b/src/driver/setOptions.js index b32eedd..d8281c3 100644 --- a/src/driver/setOptions.js +++ b/src/driver/setOptions.js @@ -7,7 +7,7 @@ import {setGetOptions} from '../utils/setRequestOptions' const driverUri = 'v1/driver' export function setGetJobOptions (tag = 'all') { - if (tag == 'all') { + if (tag === 'all') { return setGetOptions(tag, driverUri) } } diff --git a/src/job/create.js b/src/job/create.js index ec5edf8..3919d49 100644 --- a/src/job/create.js +++ b/src/job/create.js @@ -19,11 +19,11 @@ const r = require('request-promise') // } export function createJob (jobName, fromLinkConf, toLinkConf) { - // TODO + // TODO const options = setCreateOrUpdateJobOptions(jobName, fromLinkConf, toLinkConf) console.log(options['body']['jobs']) return r(options) - .then(function (repos) { - return repos - }) + .then(function (repos) { + return repos + }) } diff --git a/src/job/delete.js b/src/job/delete.js index e1de86c..66c373a 100644 --- a/src/job/delete.js +++ b/src/job/delete.js @@ -10,11 +10,11 @@ const r = require('request-promise') export function deleteJob (jobName) { const options = setDeleteJobOptions(jobName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export async function deleteJobAll () { diff --git a/src/job/get.js b/src/job/get.js index 8b7e8f5..8d4bcae 100644 --- a/src/job/get.js +++ b/src/job/get.js @@ -9,32 +9,32 @@ const r = require('request-promise') export function getJobAll () { const options = setGetJobOptions('all') return r(options) - .then(function (repos) { - return repos['jobs'] - }) - .catch(function (err) { + .then(function (repos) { + return repos['jobs'] + }) + .catch(function (err) { - }) + }) } export function getJobByJobName (jobName) { const options = setGetJobOptions('subName', jobName) return r(options) - .then(function (repos) { - return repos['jobs'] - }) - .catch(function (err) { + .then(function (repos) { + return repos['jobs'] + }) + .catch(function (err) { - }) + }) } export function getJobByConnectorName () { const options = setGetJobOptions('cname', connectorName) return r(options) - .then(function (repos) { - return repos['jobs'] - }) - .catch(function (err) { + .then(function (repos) { + return repos['jobs'] + }) + .catch(function (err) { - }) + }) } diff --git a/src/job/setOptions.js b/src/job/setOptions.js index 001671b..92bdcdc 100644 --- a/src/job/setOptions.js +++ b/src/job/setOptions.js @@ -8,35 +8,35 @@ import {setMysqlConfig, setHdfsConfig} from './setTemplate' const jobUri = 'v1/job' export function setGetJobOptions (tag, jobOrConnectorName = null) { - if (tag == 'all') { + if (tag === 'all') { return setGetOptions(tag, jobUri) - } else if (tag == 'jobName') { + } else if (tag === 'jobName') { return setGetOptions(tag, jobUri, jobOrConnectorName) - } else if (tag == 'cname') { + } else if (tag === 'cname') { return setGetOptions('cname', jobUri, jobOrConnectorName) } } export function setCreateOrUpdateJobOptions (jobName, fromLinkConf, toLinkConf) { - // TODO - // from + // TODO + // from let fromConfigValues - if (fromLinkConf['type'] == 'mysql') { + if (fromLinkConf['type'] === 'mysql') { fromConfigValues = setMysqlConfig(fromLinkConf) fromLinkConf['connectorName'] = 'generic-jdbc-connector' - } else if (fromLinkConf['type'] == 'hdfs') { + } else if (fromLinkConf['type'] === 'hdfs') { fromConfigValues = setHdfsConfig(fromLinkConf) fromLinkConf['connectorName'] = 'hdfs-connector' } else { throw Error() } - // to + // to let toConfigValues - if (toLinkConf['type'] == 'mysql') { + if (toLinkConf['type'] === 'mysql') { toConfigValues = setMysqlConfig(toLinkConf) toLinkConf['connectorName'] = 'generic-jdbc-connector' - } else if (toLinkConf['type'] == 'hdfs') { + } else if (toLinkConf['type'] === 'hdfs') { toConfigValues = setHdfsConfig(toLinkConf) toLinkConf['connectorName'] = 'hdfs-connector' } else { @@ -118,7 +118,7 @@ export function setDeleteJobOptions (jobName) { } export function setUpdateJobOptions (tag, jobName) { - if (tag == 'enable' || tag == 'disable') { + if (tag === 'enable' || tag === 'disable') { return setPutOptions('enable', jobUri, jobName) } } diff --git a/src/job/update.js b/src/job/update.js index af230ac..a8e88be 100644 --- a/src/job/update.js +++ b/src/job/update.js @@ -7,31 +7,31 @@ import {setUpdateJobOptions, setCreateOrUpdateJobOptions} from './setOptions' const r = require('request-promise') export function updateJob (jobName, fromLinkConf, toLinkConf) { - // TODO + // TODO const options = setCreateOrUpdateJobOptions(jobName, fromLinkConf, toLinkConf) console.log(options['body']['jobs']) return r(options) - .then(function (repos) { - return repos - }) + .then(function (repos) { + return repos + }) } export function updateJobEnable (jobName) { const options = setUpdateJobOptions('enable', jobName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export function updateJobDisable (jobName) { const options = setUpdateJobOptions('disable', jobName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } diff --git a/src/link/create.js b/src/link/create.js index 209d340..10806bd 100644 --- a/src/link/create.js +++ b/src/link/create.js @@ -22,13 +22,13 @@ const r = require('request-promise') // } export function createLink (linkName, param) { - // TODO 各种参数 + // TODO 各种参数 const options = setCreateLinkOptions(linkName, param) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { + .then(function (repos) { + return repos + }) + .catch(function (err) { - }) + }) } diff --git a/src/link/delete.js b/src/link/delete.js index 34bd4e7..475b48c 100644 --- a/src/link/delete.js +++ b/src/link/delete.js @@ -10,11 +10,11 @@ const r = require('request-promise') export function deleteLink (linkName) { const options = setDeleteLinkOptions(linkName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export async function deleteLinkAll () { diff --git a/src/link/get.js b/src/link/get.js index 4edcb2d..9fc4bda 100644 --- a/src/link/get.js +++ b/src/link/get.js @@ -9,29 +9,29 @@ const r = require('request-promise') export function getLinkAll () { const options = setGetLinkOptions('all') return r(options) - .then(function (repos) { - return repos['links'] - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos['links'] + }) + .catch(function (err) { + }) } export function getLinkByLinkName (linkName) { const options = setGetLinkOptions('subName', linkName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export function getLinkByConnectorName (connectorName) { const options = setGetLinkOptions('cname', connectorName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } diff --git a/src/link/setOptions.js b/src/link/setOptions.js index 2fcd3f1..db8a4f3 100644 --- a/src/link/setOptions.js +++ b/src/link/setOptions.js @@ -8,7 +8,7 @@ const linkUri = 'v1/link' export function setCreateLinkOptions (linkName, param) { const body = {} - if (param['DatabaseType'] == 'mysql') { + if (param['DatabaseType'] === 'mysql') { const uri = encodeURIComponent('jdbc:mysql://' + param['connectionHost'] + ':' + param['connectionPort']) body['links'] = [ { @@ -74,15 +74,15 @@ export function setCreateLinkOptions (linkName, param) { 'overrides': '', 'type': 'INTEGER' }, { - 'editable': 'ANY', - 'validators': [], - 'name': 'linkConfig.jdbcProperties', - 'id': 72, - 'sensitive': false, - 'overrides': '', - 'type': 'MAP', - 'sensitive-pattern': '' - } + 'editable': 'ANY', + 'validators': [], + 'name': 'linkConfig.jdbcProperties', + 'id': 72, + 'sensitive': false, + 'overrides': '', + 'type': 'MAP', + 'sensitive-pattern': '' + } ], 'name': 'linkConfig', 'id': 17, @@ -112,13 +112,13 @@ export function setCreateLinkOptions (linkName, param) { } ] - } else if (param['type'] == 'hdfs') { - // TODO - // param['uri'] = 's3a://sqoop2/' - // param['s3'] = {} - // param['s3']['access'] = 'AKIAOISG3IRVOIUP2PNA' - // param['s3']['secret'] = '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' - // param['s3']['region'] = 's3.cn-north-1.amazonaws.com.cn' + } else if (param['type'] === 'hdfs') { + // TODO + // param['uri'] = 's3a://sqoop2/' + // param['s3'] = {} + // param['s3']['access'] = 'AKIAOISG3IRVOIUP2PNA' + // param['s3']['secret'] = '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' + // param['s3']['region'] = 's3.cn-north-1.amazonaws.com.cn' body['links'] = [ { 'id': -1, @@ -189,17 +189,17 @@ export function setDeleteLinkOptions (linkName) { } export function setGetLinkOptions (tag = 'all', linkOrConnectorName = null) { - if (tag == 'all') { + if (tag === 'all') { return setGetOptions(tag, linkUri) - } else if (tag == 'subName') { + } else if (tag === 'subName') { return setGetOptions(tag, linkUri, linkOrConnectorName) - } else if (tag == 'cname') { + } else if (tag === 'cname') { return setGetOptions('cname', linkUri, linkOrConnectorName) } } export function setUpdateOptions (tag, linkName) { - if (tag == 'enable' || tag == 'disable') { + if (tag === 'enable' || tag === 'disable') { return setPutOptions('enable', linkUri, linkName) } } diff --git a/src/link/update.js b/src/link/update.js index ba0e5c5..93c7adf 100644 --- a/src/link/update.js +++ b/src/link/update.js @@ -9,22 +9,22 @@ const r = require('request-promise') export function updateEnable (linkName) { const options = setUpdateOptions('enable', linkName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export function updateDisable (linkName) { const options = setUpdateOptions('disable', linkName) return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos + }) + .catch(function (err) { + }) } export function updateLink (linkName) { - // TODO + // TODO } diff --git a/src/submission/get.js b/src/submission/get.js index 5464cb6..e6d6b13 100644 --- a/src/submission/get.js +++ b/src/submission/get.js @@ -9,11 +9,11 @@ const r = require('request-promise') export function getSubmissionALL () { const options = setGetSubmissionOptions('all') return r(options) - .then(function (repos) { - return repos['links'] - }) - .catch(function (err) { - }) + .then(function (repos) { + return repos['links'] + }) + .catch(function (err) { + }) } export function getSubmissionByJobName () { diff --git a/src/submission/setOptions.js b/src/submission/setOptions.js index 6943cb2..e2594cb 100644 --- a/src/submission/setOptions.js +++ b/src/submission/setOptions.js @@ -20,7 +20,7 @@ export function setGetJobStatusOptions (jobName) { } export function setGetSubmissionOptions (tag = 'all') { - if (tag == 'all') { + if (tag === 'all') { return setGetOptions(tag, submissionUri) } } diff --git a/src/submission/status.js b/src/submission/status.js index b86dac1..9b7ce83 100644 --- a/src/submission/status.js +++ b/src/submission/status.js @@ -9,37 +9,37 @@ const r = require('request-promise') export function startJob (jobName) { const options = setStartJobOptions(jobName) return r(options) - .then(function (repos) { - console.log(repos) - return repos - }) - .catch(function (err) { + .then(function (repos) { + console.log(repos) + return repos + }) + .catch(function (err) { - }) + }) } export function stopJob (jobName) { const options = setStopJobOptions(jobName) return r(options) - .then(function (repos) { - console.log(repos) - return repos - }) - .catch(function (err) { + .then(function (repos) { + console.log(repos) + return repos + }) + .catch(function (err) { - }) + }) } export function getJobStatus (jobName) { const options = setGetJobStatusOptions(jobName) return r(options) - .then(function (repos) { - console.log(repos) - return repos - }) - .catch(function (err) { + .then(function (repos) { + console.log(repos) + return repos + }) + .catch(function (err) { - }) + }) } getJobStatus('movie_s3') diff --git a/src/utils/getVersion.js b/src/utils/getVersion.js index a862922..e685fd6 100644 --- a/src/utils/getVersion.js +++ b/src/utils/getVersion.js @@ -20,10 +20,10 @@ function setGetVersionOptions () { export function getVersion () { const options = setGetVersionOptions() return r(options) - .then(function (repos) { - return repos - }) - .catch(function (err) { + .then(function (repos) { + return repos + }) + .catch(function (err) { - }) + }) } diff --git a/src/utils/setRequestOptions.js b/src/utils/setRequestOptions.js index 4881dbe..cbf23c4 100644 --- a/src/utils/setRequestOptions.js +++ b/src/utils/setRequestOptions.js @@ -5,7 +5,7 @@ import {userName, baseUrl} from '../constants' export function setGetOptions (tag, uri, linkOrJobOrConnectorName = null) { - if (tag == 'all') { + if (tag === 'all') { return { method: 'GET', uri: baseUrl + uri + '/' + tag, @@ -14,7 +14,7 @@ export function setGetOptions (tag, uri, linkOrJobOrConnectorName = null) { }, json: true } - } else if (tag == 'subName') { + } else if (tag === 'subName') { return { method: 'GET', uri: baseUrl + uri + '/' + linkOrJobOrConnectorName, @@ -23,7 +23,7 @@ export function setGetOptions (tag, uri, linkOrJobOrConnectorName = null) { }, json: true } - } else if (tag == 'lname') { + } else if (tag === 'lname') { return { method: 'GET', uri: baseUrl + uri + '/' + linkOrJobOrConnectorName, @@ -32,7 +32,7 @@ export function setGetOptions (tag, uri, linkOrJobOrConnectorName = null) { }, json: true } - } else if (tag == 'cname') { + } else if (tag === 'cname') { return { method: 'GET', uri: baseUrl + uri + '/' + linkOrJobOrConnectorName, @@ -42,7 +42,7 @@ export function setGetOptions (tag, uri, linkOrJobOrConnectorName = null) { }, json: true } - } else if (tag == 'status') { + } else if (tag === 'status') { return { method: 'GET', uri: baseUrl + uri + '/' + linkOrJobOrConnectorName + '/status', @@ -70,7 +70,7 @@ export function setPostOptions (uri, body) { } export function setPutOptions (tag, uri, linkOrJobName) { - if (tag == 'enable' || tag == 'disable') { + if (tag === 'enable' || tag === 'disable') { return { method: 'PUT', uri: baseUrl + uri + '/' + linkOrJobName + '/' + tag, @@ -79,7 +79,7 @@ export function setPutOptions (tag, uri, linkOrJobName) { }, json: true } - } else if (tag == 'start' || tag == 'stop') { + } else if (tag === 'start' || tag === 'stop') { return { method: 'PUT', uri: baseUrl + uri + '/' + linkOrJobName + '/' + tag,