mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
feat: add qualifier option to invoke command
This commit is contained in:
parent
929d22f969
commit
70fa0d82dd
@ -27,6 +27,7 @@ serverless invoke [local] --function functionName
|
||||
- `--function` or `-f` The name of the function in your service that you want to invoke. **Required**.
|
||||
- `--stage` or `-s` The stage in your service you want to invoke your function in.
|
||||
- `--region` or `-r` The region in your stage that you want to invoke your function in.
|
||||
- `--qualifier` or `-q` The version number or alias to invoke your function in. Default is `$LATEST`.
|
||||
- `--data` or `-d` String data to be passed as an event to your function. By default data is read from standard input.
|
||||
- `--raw` Pass data as a raw string even if it is JSON. If not set, JSON data are parsed and passed as an object.
|
||||
- `--path` or `-p` The path to a json file with input data to be passed to the invoked function. This path is relative to the root directory of the service.
|
||||
|
||||
@ -77,6 +77,10 @@ class AwsInvoke {
|
||||
Payload: new Buffer(JSON.stringify(this.options.data || {})),
|
||||
};
|
||||
|
||||
if (this.options.qualifier) {
|
||||
params.Qualifier = this.options.qualifier;
|
||||
}
|
||||
|
||||
return this.provider.request('Lambda', 'invoke', params);
|
||||
}
|
||||
|
||||
|
||||
@ -265,6 +265,26 @@ describe('AwsInvoke', () => {
|
||||
awsInvoke.provider.request.restore();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to invoke with a qualifier', () => {
|
||||
awsInvoke.options.qualifier = 'somelongqualifier';
|
||||
|
||||
return awsInvoke.invoke().then(() => {
|
||||
expect(invokeStub.calledOnce).to.be.equal(true);
|
||||
|
||||
expect(
|
||||
invokeStub.calledWithExactly('Lambda', 'invoke', {
|
||||
FunctionName: 'customName',
|
||||
InvocationType: 'RequestResponse',
|
||||
LogType: 'None',
|
||||
Payload: new Buffer(JSON.stringify({})),
|
||||
Qualifier: 'somelongqualifier',
|
||||
})
|
||||
).to.be.equal(true);
|
||||
|
||||
awsInvoke.provider.request.restore();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#log()', () => {
|
||||
|
||||
@ -28,6 +28,10 @@ class Invoke {
|
||||
usage: 'Region of the service',
|
||||
shortcut: 'r',
|
||||
},
|
||||
qualifier: {
|
||||
usage: 'Version number or alias to invoke',
|
||||
shortcut: 'q',
|
||||
},
|
||||
path: {
|
||||
usage: 'Path to JSON or YAML file holding input data',
|
||||
shortcut: 'p',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user