Skip to content

Properly supporting sls deploy function command and zip option #217

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

Merged
merged 3 commits into from
Jul 10, 2018

Conversation

chongkong
Copy link
Contributor

This PR fixes two issues I encountered while using individually: true option.

1. Should package only the given function when invoked by sls deploy function --function $FN_NAME

Suppose using individually: true. If you'd like to deploy a single function using sls deploy function command you'd expect the plugin to package only the module that contains the function specified. The current implementation, however, runs packaging for every module in serverless.yml definition, taking as much time as deploying all applications just to deploy a single function.

I simply added explicit targetFuncs property to filter target function if any specified in command line option.

2. moveModulesUp should be called regardless of zip option

When individually: true, each deployed function has its module as a root directory. This is achieved by calling moveModulesUp, but this method call is ignored when zip option is enabled. This certainly seems to be a wrong implementation (causing #203). If injectModule is ensured not to be called when zip: true, it is safe to call moveModulesUp whether zip is enabled or not.

The fix seems to work well on my case, but it lacks new unit tests (I couldn't figure out how to compose one.) If you let me known how to add a test, I'll update the PR as soon as I can.

@chongkong
Copy link
Contributor Author

Oops lint error

Copy link
Contributor

@AndrewFarley AndrewFarley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good catch

Copy link
Contributor

@dschep dschep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks @chongkong!

I'd love it for this to be tested, but don't really know what the best way to test deployment 😢

@dschep dschep merged commit 37adf9e into serverless:master Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants