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

feat: Eliminate need for 'x-azure-settings' config #404

Merged
merged 3 commits into from
Apr 21, 2020

Conversation

tbarlow12
Copy link
Collaborator

What did you implement:

Users can now place the configuration in the event object rather than inside the nested x-azure-settings configuration. Users can still use x-azure-settings if they want. This is NOT a breaking change

Closes #371 and #12

How did you implement it:

  • Made x-azure-settings to be optional member of interface
  • To maintain backwards compatibility, the binding utilities will first check to see if x-azure-functions is defined on the event object. If it is not, the event itself is used.
  • The Func plugin and service that generate the .yml file were also updated to reflect the change
  • Changes to the MockFactory, tests, and documentation were made to reflect the change

How can we verify it:

  • Take any existing project, move the settings contained within x-azure-settings up one level and run sls offline. The bindings are generated correctly

Todos:

Note: Run npm run test:ci to run all validation checks on proposed changes

  • Ensure there are no lint errors.
    Validate via npm run lint
    Note: Some reported issues can be automatically fixed by running npm run lint:fix
  • Write tests and confirm existing functionality is not broken.
    Validate via npm test
  • Write documentation
  • 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

@tbarlow12 tbarlow12 requested review from wbreza and mydiemho and removed request for wbreza March 6, 2020 20:40
Copy link
Member

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

I've always hated the x-azure-settings... Thanks for doing this!
Looks good - I have a few suggestions.

src/models/serverless.ts Show resolved Hide resolved
return functionConfig.events.find((event) => {
const settings = event["x-azure-settings"]
const settings = Utils.get(event, constants.xAzureSettings, event);
Copy link
Member

Choose a reason for hiding this comment

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

Consider reusing this constant in other places where the raw text is still duplicated.

@@ -334,15 +334,15 @@ export class MockFactory {
};
}

public static createTestFunctionMetadata(name: string): ServerlessAzureFunctionConfig {
public static createTestFunctionMetadata(name: string, xAzureSettings: boolean = true): ServerlessAzureFunctionConfig {
Copy link
Member

Choose a reason for hiding this comment

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

Seems a little messy to add a new param to all these mock methods special for the xAzureSettings case. Maybe consider creating new mock method for testing?

@tbarlow12 tbarlow12 merged commit cbd9173 into dev Apr 21, 2020
@tbarlow12 tbarlow12 deleted the tabarlow/x-azure-settings branch April 30, 2020 13:11
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

2 participants