serverless-offline
serverless-offline copied to clipboard
Per function ignore functionality
Description
Give the ability for serverless-offline to be selectively disabled on a function-by-function basis.
Motivation and Context
I have a scheduled-event based function that isn't properly configured for offline use (and I'd prefer not to put the work in just to get it working on local for a toy project). Rather than being able to just conveniently, selectively disable it, it just errors over and over in my console output.
How Has This Been Tested?
I ran tests in two ways:
- Acceptance testing via
yarn link
in my own project to be sure that my local version ran correctly - Two added e2e tests within the project itself
I was able to do the following:
- Add the
serverless-offline-ignore: true
flag to the scheduled-event based function that I didn't want running locally and watch it be disabled - Visually confirm that the new e2e tests pass within the project itself
Concerns
- I wasn't able to get groovy tests to pass locally (but they weren't passing on HEAD on my local machine). I've ignored them - but would love it if anyone who has the groovy tests passing can verify.
- I get the following serverless log warning:
Serverless: Configuration warning:
Serverless: at 'functions.checksiteregen': unrecognized property 'serverless-offline-ignore'
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:
Serverless: Deprecation warning: Starting with next major, Serverless will throw on configuration errors by default. Adapt to this behavior now by adding "configValidationMode: error" to service configuration
More Info: https://www.serverless.com/framework/docs/deprecations/#CONFIG_VALIDATION_MODE_DEFAULT
So this might start erroring for users by default at the next major serverless version. Worth maybe adding documentation around this so that users can pre-add configValidationMode: off
? That even seems problematic. I don't see a warn
anywhere to revert it back to just warnings. Definitely open to feedback on what to do about that.
Hi @anonmos , could you give us an update?
Hi @anonmos , could you give us an update?
Hello @dherault! Apologies, the company that I was working with shut down and this got lost in the shuffle.
I believe all that needs to be done is to extend the serverless.yml syntax with custom configuration. I'll have a look at that this weekend and get it working.
Hello @pgrzesik and @dherault, I've made the update that should allow this to work without warnings / errors. I've tested this with my old project and it seems to work properly with Serverless >= v3 with no warnings.
Please let me know if you see anything else that would benefit this PR!
@anonmos thank you for the PR and putting in the work. I agree with @pgrzesik that it would be better not to extend the serverless
schema config but instead use the custom
section.
that said, for your particular use case, you can just use the events.schedule.enabled
section of the serverless config to enable or disable scheduled events. Please let me know if that helps your scenario.
I'm closing this PR for good housekeeping.