apache / apache/openwhisk-wskdeploy

Specifying action parameters in the inputs array or the annotations one

Open
#1,097 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
75
Forks
73
PR merge metrics
No merged PRs in 30d

Description

# Issue

Action parameters specified in the `inputs` array are not visible through the WSK CLI while parameters specified in the `annotations.parameters` array are visible.

# Expected behaviour

How the `inputs` and `annotations.parameters` arrays work should be documented and the tests should reflect this.

# Details

I am trying to specify action parameters in the manifest so that those parameters are visible when you run `wsk package get --summary`. Reading through [the wskdeploy tests](https://github.com/apache/openwhisk-wskdeploy/blob/master/tests/src/integration/validate-action-annotations/manifest.yaml) suggests that this should be done usign the `inputs` field so I created this manifest:

```yaml
packages:
hello:
version: 0.0.1
license: ISC
actions:
hello:
function: hello.js
runtime: 'nodejs:10'
inputs:
name:
type: string
description: name of a person
place:
type: string
description: location of a person
```

However, when I deploy this and get the package summary, I get `none defined` (queried via the `ibmcloud` CLI):

```bash
$ bx wsk package get hello --summary
package /ConsiderateGroupDev_bruno/hello
(parameters: none defined)
action /ConsiderateGroupDev_bruno/hello/hello
(parameters: none defined)
```

Looking through the [cloudant package install script](https://raw.githubusercontent.com/apache/openwhisk-package-cloudant/master/installCatalog.sh), it uses `annotations` and `parameters` instead so I created a different manifest:

```yaml
packages:
hello:
version: 0.0.1
license: ISC
actions:
hello:
function: hello.js
runtime: 'nodejs:10'
annotations:
description: Generate a simple greeting message
parameters:
- name: name
required: false
description: the name of a person
- name: place
required: false
description: location of a person
```

When deployed, the parameters for the action are now documented:

```bash
$ bx wsk package get hello --summary
package /ConsiderateGroupDev_bruno/hello
(parameters: none defined)
action /ConsiderateGroupDev_bruno/hello/hello: Generate a simple greeting message
(parameters: name, place)
```

I therefore assume that:
- the first form allows you to specify the value of inputs in a deployment manifest,
- the second form allows you to specify details of inputs as annotations for documentation purposes.

If this is correct, both forms should be included in the tests and documented. From the perspective of developers writing manifests, having two forms is confusing, especially when they overlap but don't quite do the same thing. It would be a lot easier if all parameter details, including type, value and description, where defined in the same block in the manifest, for the tool to work out how to deploy it.

For completeness, here is the code for `hello.js`:

```javascript
function main(params) {
const name = params.name || 'World';
const place = params.place || 'Space';
return {
message: `Hello ${name} in ${place}!`
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.