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

refactor(AWS Deploy): Deprecate function option in deploy command #9364

Conversation

jkklapp
Copy link
Contributor

@jkklapp jkklapp commented Apr 24, 2021

closes #9312

@codecov
Copy link

codecov bot commented Apr 24, 2021

Codecov Report

Merging #9364 (58d7d51) into master (34a9d91) will decrease coverage by 0.00%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9364      +/-   ##
==========================================
- Coverage   86.14%   86.14%   -0.01%     
==========================================
  Files         326      326              
  Lines       12436    12439       +3     
==========================================
+ Hits        10713    10715       +2     
- Misses       1723     1724       +1     
Impacted Files Coverage Δ
lib/cli/commands-schema/aws-service.js 100.00% <ø> (ø)
lib/plugins/deploy.js 94.73% <66.66%> (-5.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34a9d91...58d7d51. Read the comment docs.

Copy link
Contributor

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

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

Thank you @jkklapp 🙇 It looks like a good start, but we should be more careful with removing functionalities that might break user workflows. In this case, we should just configure deprecation message, while keeping the old functionality and warn that it will be removed with next major version.

deploy.options.package = false;
deploy.options.function = 'myfunc';
deploy.serverless.service.package.path = false;

return expect(deploy.hooks['before:deploy:deploy']()).to.be.fulfilled.then(() =>
BbPromise.all([
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not change this test - we still want to keep testing the old behavior until we remove it.

@@ -79,18 +79,14 @@ describe('Deploy', () => {
);
});

it('should execute deploy function if a function option is given', () => {
it('should log a deprecation message if a function option is given', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually don't test deprecation messages and I think we can skip test in this case as well. Otherwise, please configure the test with runServerless

'CLI_DEPLOY_FUNCTION_OPTION',
'The `--function` or `-f` option for `deploy` command has been r' +
'emoved. Please use `sls deploy function` command instead.'
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR should only implement a deprecation notice, without removing the functionality.


<a name="CLI_DEPLOY_FUNCTION_OPTION"><div>&nbsp;</div></a>

## CLI deploy command function option removed
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's phrase the whole message so it explains that the flag has been deprecated and will be removed with next major (3.0.0).

@jkklapp jkklapp force-pushed the deprecation/function_option_in_deploy_command branch 3 times, most recently from 3b43652 to 998274a Compare April 30, 2021 17:09
@jkklapp jkklapp requested a review from pgrzesik April 30, 2021 17:15
Copy link
Contributor

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

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

Thank you @jkklapp 🙇 I've added some suggestions to the deprecation message wording - please let me know what do you think 🙇

@@ -363,3 +363,12 @@ Please use `onUnauthenticatedRequest` instead. `allowUnauthenticated` will be re
Deprecation code: `BIN_SERVERLESS`

Please use `bin/serverless.js` instead. `bin/serverless` will be removed with v2.0.0

<a name="CLI_DEPLOY_FUNCTION_OPTION"><div>&nbsp;</div></a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put it at the top of the file, right below instructions on how to disable specific deprecations


Deprecation code: `CLI_DEPLOY_FUNCTION_OPTION'`

The `--function` or `-f` option in `deploy` command has been deprecated and will be removed in the next major release (3.0.0). Please use
Copy link
Contributor

Choose a reason for hiding this comment

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

To follow the convention of other messages in deprecations, let's maybe go with

Starting with v3.0.0, `--function` or `-f` option for `deploy` command will be removed. In order to deploy a single function, please use `deploy function` command instead. 

@@ -39,6 +39,11 @@ class Deploy {
throw new ServerlessError(errorMessage);
}
if (this.options.function) {
this.serverless.logDeprecation(
'CLI_DEPLOY_FUNCTION_OPTION',
'The `--function` or `-f` option for `deploy` command has been' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the same message as suggested in the deprecation document.

@jkklapp jkklapp requested a review from pgrzesik May 3, 2021 08:58
Copy link
Contributor

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

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

Thank you @jkklapp - I've reviewed the implementation proposal in the original ticket again and I have two questions as the implementation differs a bit from the suggested approach - I would appreciate clarification on these 🙇

@@ -36,6 +36,10 @@ class Deploy {
throw new ServerlessError(errorMessage, 'INVALID_PROVIDER');
}
if (this.options.function) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I've consulted the implementation proposal in the ticket and I believe the suggestion was to implement it as a part of newly introduced initialize hook. Was there a reason to not follow the proposal here? The general approach is to emit deprecations as a part of initialize hooks

@@ -26,7 +26,7 @@ commands.set('deploy', {
type: 'boolean',
},
'function': {
usage: "Function name. Deploys a single function (see 'deploy function')",
usage: "Function name. Deploys a single function. DEPRECATED: use 'deploy function' instead.",
Copy link
Contributor

Choose a reason for hiding this comment

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

According to proposal, it was suggested to remove this option from the schema - what was the reason against doing so?

Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to stay in schema, otherwise it will not be properly recognized and the expected deprecation won't be reported

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's probably right to keep it (same way as keep schema for deprecated config properties)

@pgrzesik pgrzesik force-pushed the deprecation/function_option_in_deploy_command branch from abba10f to 58d7d51 Compare June 29, 2021 11:18
@pgrzesik pgrzesik added cat/deployment deprecation Deprecation proposal (breaking with next major) labels Jun 29, 2021
@pgrzesik pgrzesik self-assigned this Jun 29, 2021
@pgrzesik pgrzesik requested a review from medikoo June 29, 2021 11:27
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

👍 Looks great

@@ -26,7 +26,7 @@ commands.set('deploy', {
type: 'boolean',
},
'function': {
usage: "Function name. Deploys a single function (see 'deploy function')",
usage: "Function name. Deploys a single function. DEPRECATED: use 'deploy function' instead.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's probably right to keep it (same way as keep schema for deprecated config properties)

@pgrzesik pgrzesik changed the title deprecate function option in deploy command refactor(AWS Deploy): Deprecate function option in deploy command Jun 29, 2021
@pgrzesik pgrzesik merged commit d861d11 into serverless:master Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat/deployment deprecation Deprecation proposal (breaking with next major)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: Deprecate sls deploy -f <function-name>
3 participants