Skip to content
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

Allow to provide a default value for plugin options #3808

Merged
merged 2 commits into from Jul 19, 2017

Conversation

rpunkfu
Copy link
Contributor

@rpunkfu rpunkfu commented Jun 18, 2017

What did you implement:

Functionality that allows user to specify default values for plugin options.

Closes #2242

How did you implement it:

Options without a value will be assigned a default value, if it's specified.

How can we verify it:

Specifying default in any of the options, ensures that it will be that option's value, unless we set it manually via cli.

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@rpunkfu rpunkfu force-pushed the specify-default-option-values branch from 4769401 to da105b3 Compare June 18, 2017 01:56
@horike37
Copy link
Member

@rpunkfu
Unfortunately, linting error has occurred. Could you fix this?

/home/travis/build/serverless/serverless/lib/classes/PluginManager.js
  360:8  error  Unnecessary semicolon  no-extra-semi

@pmuens pmuens self-requested a review June 18, 2017 08:58
@pmuens pmuens added this to the 1.17 milestone Jun 18, 2017
@rpunkfu rpunkfu force-pushed the specify-default-option-values branch from da105b3 to da9d7c2 Compare June 18, 2017 08:59
@rpunkfu
Copy link
Contributor Author

rpunkfu commented Jun 18, 2017

I fixed that linting error @horike37, thanks for pointing it out :)

@pmuens pmuens removed this from the 1.17 milestone Jun 18, 2017
@rpunkfu rpunkfu force-pushed the specify-default-option-values branch from da9d7c2 to 4d994b8 Compare June 18, 2017 14:28
@rpunkfu rpunkfu force-pushed the specify-default-option-values branch from 4d994b8 to d9dcd73 Compare June 19, 2017 19:11
@@ -352,6 +353,13 @@ class PluginManager {
});
}

assignDefaultOptions(command) {
_.forEach(command.options, (value, key) => {
if (value.default && (!this.cliOptions[key] || this.cliOptions[key] === true)) {
Copy link
Member

Choose a reason for hiding this comment

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

I might be boolean-lost here, but why do we need this.cliOptions[key] === true condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

lol #guilty 😂 ... @pmuens would be great if you could shed some light here ☺️

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@rpunkfu rpunkfu Jul 15, 2017

Choose a reason for hiding this comment

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


;pp

Copy link
Contributor

Choose a reason for hiding this comment

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

these_accusations === false && these_accusations !== true

I have no idea how it got there :D I did a lot of cut pasting when I did that refactor.....

Copy link
Contributor

Choose a reason for hiding this comment

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

😂 thanks for the response @dougmoscrop.

So I would say that we can get rid of the double check since they really both check the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

😬 Thanks @dougmoscrop --> ⛹️

So as the author of this weird piece of code I'd say that we can drop 😂

Copy link
Member

Choose a reason for hiding this comment

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

looks like this is going further than I thought 😄 ... it needs further investigation and testing 😊

Copy link
Member

@eahefnawy eahefnawy left a comment

Choose a reason for hiding this comment

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

Just tried this out and it's working great! Couldn't break it.

I've also pushed some docs for the new feature! Thanks @rpunkfu

G2M! 💥

@eahefnawy eahefnawy added this to the 1.18 milestone Jul 19, 2017
@eahefnawy eahefnawy merged commit de6bebe into serverless:master Jul 19, 2017
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.

None yet

5 participants