Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 4855c01

Browse files
committed
fix for semi-broken invoke --param-file
Fixes #487
1 parent 50dfebd commit 4855c01

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

app/plugins/ui/commands/openwhisk-core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const paramFile = (M, idx, argv, type) => {
196196
const params = JSON.parse(require('fs').readFileSync(expandHomeDir(file)).toString())
197197
M[type].parameters = M[type].parameters.concat(toArray(params))
198198

199-
return idx
199+
return idx + 1
200200
}
201201

202202
const isBinary = {
@@ -804,6 +804,7 @@ const executor = (_entity, _verb, verbSynonym, commandTree, preflight) => (block
804804
//
805805
// OPERATION WITH IMPLICIT ENTITY: try to get the name from the current selection
806806
//
807+
debug('seeing if we can use an implicit entity')
807808
const sidecar = document.querySelector('#sidecar')
808809
if (sidecar && sidecar.entity) {
809810
options.name = `/${sidecar.entity.namespace || '_'}/${sidecar.entity.name}`

app/plugins/ui/commands/openwhisk-usage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const activationID = [{ name: 'activationId', docs: 'an activation ID', entity:
5555

5656
/** optional parameters having to do with parameter bindings */
5757
const params = [{ name: '--param', alias: '-p', example: 'key value', docs: 'bind a variable to a value', narg: 2, key: 'parameters' },
58-
{ name: '--param-file', alias: '-P', advanced: true, docs: 'a local path to a bindings file' }]
58+
{ name: '--param-file', alias: '-P', advanced: true, docs: 'a local path to a bindings file', file: true }]
5959

6060
/** optional parameters having to do with annotations */
6161
const annotations = [{ name: '--annotation', alias: '-a', example: 'key value', docs: 'annotate a variable with a value', narg: 2, key: 'annotations' },

tests/tests/passes/03/invoke-implicit.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const common = require('../../../lib/common'),
1818
openwhisk = require('../../../lib/openwhisk'),
1919
ui = require('../../../lib/ui'),
2020
assert = require('assert'),
21+
path = require('path'),
2122
keys = ui.keys,
2223
cli = ui.cli,
2324
sidecar = ui.sidecar,
@@ -46,6 +47,32 @@ describe('wsk action invoke with implicit entity', function() {
4647
.catch(common.oops(this)))
4748
}
4849

50+
const paramsJson = require(path.join(__dirname, '../../../data/params.json'))
51+
52+
it(`should invoke ${actionName} with implicit entity and --param-file`, () => cli.do(`invoke --param-file ./data/params.json`, this.app)
53+
.then(cli.expectOK)
54+
.then(sidecar.expectOpen)
55+
.then(sidecar.expectShowing(actionName))
56+
.then(() => this.app.client.getText(ui.selectors.SIDECAR_ACTIVATION_RESULT))
57+
.then(ui.expectStruct(Object.assign({ x:3 }, paramsJson )))
58+
.catch(common.oops(this)))
59+
60+
it(`should invoke ${actionName} with implicit entity and -P`, () => cli.do(`invoke -P ./data/params.json`, this.app)
61+
.then(cli.expectOK)
62+
.then(sidecar.expectOpen)
63+
.then(sidecar.expectShowing(actionName))
64+
.then(() => this.app.client.getText(ui.selectors.SIDECAR_ACTIVATION_RESULT))
65+
.then(ui.expectStruct(Object.assign({ x:3 }, paramsJson )))
66+
.catch(common.oops(this)))
67+
68+
it(`should invoke ${actionName} with explicit entity and -P`, () => cli.do(`invoke ${actionName} -P ./data/params.json`, this.app)
69+
.then(cli.expectOK)
70+
.then(sidecar.expectOpen)
71+
.then(sidecar.expectShowing(actionName))
72+
.then(() => this.app.client.getText(ui.selectors.SIDECAR_ACTIVATION_RESULT))
73+
.then(ui.expectStruct(Object.assign({ x:3 }, paramsJson )))
74+
.catch(common.oops(this)))
75+
4976
it(`should fail when requesting parameters of an activation`, () => cli.do('params', this.app)
5077
.then(cli.expectError(0, 'The current entity does not support viewing parameters'))
5178
.catch(common.oops(this)))

0 commit comments

Comments
 (0)