-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make --no-event the default for local invoke #1477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,14 +14,17 @@ | |
|
|
||
| HELP_TEXT = """ | ||
| You can use this command to execute your function in a Lambda-like environment locally. | ||
| You can pass in the event body via stdin or by using the -e (--event) parameter. | ||
| Logs from the Lambda function will be output via stdout.\n | ||
| You can pass in an event body using the -e (--event) parameter. | ||
| Logs from the Lambda function will be written to stdout.\n | ||
| \b | ||
| Invoking a Lambda function without an input event | ||
| $ sam local invoke "HelloWorldFunction"\n | ||
| \b | ||
| Invoking a Lambda function using an event file | ||
| $ sam local invoke "HelloWorldFunction" -e event.json\n | ||
| \b | ||
| Invoking a Lambda function using input from stdin | ||
| $ echo '{"message": "Hey, are you there?" }' | sam local invoke "HelloWorldFunction" \n | ||
| $ echo '{"message": "Hey, are you there?" }' | sam local invoke "HelloWorldFunction" --event - \n | ||
| """ | ||
| STDIN_FILE_NAME = "-" | ||
|
|
||
|
|
@@ -31,11 +34,10 @@ | |
| "--event", | ||
| "-e", | ||
| type=click.Path(), | ||
| default=STDIN_FILE_NAME, # Defaults to stdin | ||
| help="JSON file containing event data passed to the Lambda function during invoke. If this option " | ||
| "is not specified, we will default to reading JSON from stdin", | ||
| "is not specified, no event is assumed. Pass in the value '-' to input JSON via stdin", | ||
awood45 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| @click.option("--no-event", is_flag=True, default=False, help="Invoke Function with an empty event") | ||
| @click.option("--no-event", is_flag=True, default=True, help="DEPRECATED: By default no event is assumed.", hidden=True) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a plan to remove this option all together?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open to that, question is if it's worth breaking people who are already using it. But by making it hidden, we're more or less de facto deleting it. The next step would be to drop values on the floor if someone goes to the trouble of doing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we actually add a line somewhere "DEPRECATED" onto stdout, before we start looking for values on stdin. Similair to how python2.7 was deprecated.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't have I am ok not deleting it fully. You marked it as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if someone explicitly defines So perhaps the best way forward is to just leave it in place, but have it rendered inert. |
||
| @invoke_common_options | ||
| @cli_framework_options | ||
| @aws_creds_options | ||
|
|
@@ -116,14 +118,10 @@ def do_cli( # pylint: disable=R0914 | |
|
|
||
| LOG.debug("local invoke command is called") | ||
|
|
||
| if no_event and event != STDIN_FILE_NAME: | ||
| # Do not know what the user wants. no_event and event both passed in. | ||
| raise UserException("no_event and event cannot be used together. Please provide only one.") | ||
|
|
||
| if no_event: | ||
| event_data = "{}" | ||
| else: | ||
| if event: | ||
| event_data = _get_event(event) | ||
| else: | ||
| event_data = "{}" | ||
|
|
||
| # Pass all inputs to setup necessary context to invoke function locally. | ||
| # Handler exception raised by the processor for invalid args and print errors | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.