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

layers schema #8299

Merged
merged 11 commits into from Oct 1, 2020
Merged

layers schema #8299

merged 11 commits into from Oct 1, 2020

Conversation

thewizarodofoz
Copy link
Contributor

Closes: #8015

@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2020

Codecov Report

Merging #8299 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8299      +/-   ##
==========================================
- Coverage   88.02%   88.01%   -0.01%     
==========================================
  Files         249      249              
  Lines        9308     9305       -3     
==========================================
- Hits         8193     8190       -3     
  Misses       1115     1115              
Impacted Files Coverage Δ
lib/configSchema.js 100.00% <ø> (ø)
lib/plugins/aws/provider/awsProvider.js 93.04% <ø> (ø)
lib/classes/ConfigSchemaHandler/index.js 89.10% <100.00%> (ø)
lib/plugins/aws/package/compile/layers/index.js 95.45% <100.00%> (-0.15%) ⬇️

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 a6ff964...eb40629. Read the comment docs.

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.

Thank you @thewizarodofoz ! It'll be great to have that in, and it looks very promising, please see my remarks

Comment on lines 8 to 13
individually: { type: 'boolean' },
path: { type: 'string' },
artifact: { type: 'string' },
exclude: { type: 'array', items: { type: 'string' } },
include: { type: 'array', items: { type: 'string' } },
excludeDevDependencies: { type: 'boolean' },
Copy link
Contributor

Choose a reason for hiding this comment

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

As I inspect the code we only support artifact, include and exclude property on layer.package, so schema should be different from top level package property, and I think best to treat both as different.

package: {
package: packageSchema,

layers: {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an AWS specific property, so I think we should define it in context o AWS provider, in same way as resources (which also initially were defined here, but we moved it with: 6d7e967)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So should I remove layers from lib/configSchema.js altogether? or keep the simple {type: 'object'} schema there?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it should be moved completely, exactly in a same way as resources where moved with this commit: 6d7e967

],
},
},
compatibleRuntimes: { type: 'array', items: { type: 'string' }, maxItems: 5 },
Copy link
Contributor

Choose a reason for hiding this comment

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

It'll be good to rely on awsLambdaRuntime definition

items: {
oneOf: [
{ type: 'integer', minimum: 100000000000, maximum: 999999999999 },
{ type: 'string', pattern: '^\\d{12}$' },
Copy link
Contributor

Choose a reason for hiding this comment

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

oneOf: [
{ type: 'integer', minimum: 100000000000, maximum: 999999999999 },
{ type: 'string', pattern: '^\\d{12}$' },
{ const: '*' },
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove it and rely on pattern as in AWS docs

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.

@thewizarodofoz thanks for update! It looks promising, still if I see correctly, in current form this schema is totally ignored.

To have it working, we need to introduce exactly same changes as we did here 6d7e967 for resources
(note changes in lib/classes/ConfigSchemaHandler/index.js and I think it'll be nice to add documentation line at docs/providers/aws/guide/plugins.md)

{ type: 'integer', minimum: 100000000000, maximum: 999999999999 },
{
type: 'string',
pattern: '\\d{12}|\\*|arn:(aws[a-zA-Z-]*):iam::\\d{12}:root',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to enclose it with ^ and $

@thewizarodofoz
Copy link
Contributor Author

I think it'll be nice to add documentation line at docs/providers/aws/guide/plugins.md

@medikoo Not sure that I follow. If I understand correctly, resources is mentioned there in the context of "Definition for eventual top level "resources" section", but in this PR we said that layers is not a top level section (it's aws specific) so it will not be relevant to a new custom provider.

@thewizarodofoz
Copy link
Contributor Author

@medikoo I followed the same path as shown in 6d7e967, hope it's fine.
If you can, I would like to know why those are needed, couldn't figure it out from the code.

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.

@medikoo Not sure that I follow. If I understand correctly, resources is mentioned there in the context of "Definition for eventual top level "resources" section", but in this PR we said that layers is not a top level section (it's aws specific) so it will not be relevant to a new custom provider.

layers actually remain top-level, we didn't change that. We just moved it's definition to AWS context.

In this PR we move it's definition, and a capability to define layers through defineProvider schema extension utility, and to have that fully complete, it'll be great to also expose in docs that layers can be defined via defineProvider. See full docs for defineProvider: https://github.com/serverless/serverless/blob/6d7e96722721c8a5c614bea2802af7142011d35f/docs/providers/aws/guide/plugins.md#defineprovider-helper

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.

That looks great @thewizarodofoz !

Sorry for still not yet taking it in, but today one improvement landed which I believe will vastly improve service configuration handling, and which allows us to simply schema as proposed here. Please see my comment

type: 'array',
items: {
oneOf: [
{ type: 'integer', minimum: 100000000000, maximum: 999999999999 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Today I've turned on automatic coercion with #8319, and having that I believe we no longer need that number definition.

We can also remove the logic which tries to handle eventual numeric input

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.

Thank you @thewizarodofoz ! That looks great

@medikoo medikoo merged commit 4168dc1 into serverless:master Oct 1, 2020
@thewizarodofoz thewizarodofoz deleted the aws-layers-schema branch October 1, 2020 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config schema: Define "layers"
3 participants