This is an automated email from the ASF dual-hosted git repository. tardieu pushed a commit to branch kind-timeout in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-composer.git
commit a815cb471abd098648fd114b2159601f3b560906 Author: Olivier Tardieu <tard...@us.ibm.com> AuthorDate: Wed Mar 27 13:36:46 2019 -0400 Add deploy --kind and --timeout flags --- bin/deploy.js | 11 ++++++++--- client.js | 4 ++-- conductor.js | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/deploy.js b/bin/deploy.js index c2b2519..9374f99 100755 --- a/bin/deploy.js +++ b/bin/deploy.js @@ -25,9 +25,9 @@ const minimist = require('minimist') const path = require('path') const argv = minimist(process.argv.slice(2), { - string: ['apihost', 'auth', 'source', 'annotation', 'annotation-file', 'debug'], + string: ['apihost', 'auth', 'source', 'annotation', 'annotation-file', 'debug', 'kind'], boolean: ['insecure', 'version', 'overwrite'], - alias: { auth: 'u', insecure: 'i', version: 'v', annotation: 'a', 'annotation-file': 'A', overwrite: 'w' } + alias: { auth: 'u', insecure: 'i', version: 'v', annotation: 'a', 'annotation-file': 'A', overwrite: 'w', timeout: 't' } }) if (argv.version) { @@ -43,6 +43,8 @@ if (argv._.length !== 2 || path.extname(argv._[1]) !== '.json') { console.error(' -A, --annotation-file KEY=FILE add KEY annotation with FILE content') console.error(' --apihost HOST API HOST') console.error(' -i, --insecure bypass certificate checking') + console.error(' --kind KIND the KIND of the conductor action runtime') + console.error(' -t, --timeout LIMIT the timeout LIMIT in milliseconds for the conductor action') console.error(' -u, --auth KEY authorization KEY') console.error(' -v, --version output the composer version') console.error(' -w, --overwrite overwrite actions if already defined') @@ -86,7 +88,10 @@ try { console.error(error) process.exit(400 - 256) // Bad Request } -client(options).compositions.deploy(composition, argv.overwrite, argv.debug) +if (typeof argv.timeout !== 'undefined' && typeof argv.timeout !== 'number') { + throw Error('Timeout must be a number') +} +client(options).compositions.deploy(composition, argv.overwrite, argv.debug, argv.kind, argv.timeout) .then(actions => { const names = actions.map(action => action.name) console.log(`ok: created action${actions.length > 1 ? 's' : ''} ${names}`) diff --git a/client.js b/client.js index 2309e62..27fc471 100644 --- a/client.js +++ b/client.js @@ -63,8 +63,8 @@ class Compositions { this.actions = wsk.actions } - deploy (composition, overwrite, debug) { - const actions = (composition.actions || []).concat(conductor.generate(composition, debug)) + deploy (composition, overwrite, debug, kind, timeout) { + const actions = (composition.actions || []).concat(conductor.generate(composition, debug, kind, timeout)) return actions.reduce((promise, action) => promise.then(() => overwrite && this.actions.delete(action).catch(() => { })) .then(() => this.actions.create(action)), Promise.resolve()) .then(() => actions) diff --git a/conductor.js b/conductor.js index 9d73fe6..74c84bc 100644 --- a/conductor.js +++ b/conductor.js @@ -25,7 +25,7 @@ const { minify } = require('terser') const version = require('./package.json').version // synthesize conductor action code from composition -function generate ({ name, composition, ast, version: composer, annotations = [] }, debug) { +function generate ({ name, composition, ast, version: composer, annotations = [] }, debug, kind = 'nodejs:default', timeout = 60000) { let code = `// generated by composer v${composer} and conductor v${version}\n\nconst composition = ${JSON.stringify(composition, null, 4)}\n\n// do not edit below this point\n\n` + minify(`const main=(${main})(composition)`, { output: { max_line_len: 127 } }).code if (debug) code = `process.env.DEBUG='${debug}'\n\n` + code @@ -34,7 +34,7 @@ function generate ({ name, composition, ast, version: composer, annotations = [] { key: 'composerVersion', value: composer }, { key: 'conductorVersion', value: version }, { key: 'provide-api-key', value: true }]) - return { name, action: { exec: { kind: 'nodejs:default', code }, annotations } } + return { name, action: { exec: { kind, code }, annotations, limits: { timeout } } } } module.exports = { generate }