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
57 changes: 45 additions & 12 deletions lib/configSchema.js
Expand Up @@ -2,6 +2,19 @@

const functionNamePattern = '^[a-zA-Z0-9-_]+$';

const packageSchema = {
type: 'object',
properties: {
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.

},
additionalProperties: false,
};

const schema = {
type: 'object',
properties: {
Expand Down Expand Up @@ -96,22 +109,42 @@ const schema = {
additionalProperties: false,
},

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

type: 'object',
properties: {
individually: { type: 'boolean' },
path: { type: 'string' },
artifact: { type: 'string' },
exclude: { type: 'array', items: { type: 'string' } },
include: { type: 'array', items: { type: 'string' } },
excludeDevDependencies: { type: 'boolean' },
additionalProperties: {
type: 'object',
properties: {
allowedAccounts: {
type: 'array',
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.

{ 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

],
},
},
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

description: { type: 'string', maxLength: 256 },
licenseInfo: { type: 'string', maxLength: 512 },
name: {
type: 'string',
minLength: 1,
maxLength: 140,
pattern:
'^((arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\\d{12}:layer:[a-zA-Z0-9-_]+)|[a-zA-Z0-9-_]+)$',
},
package: packageSchema,
path: { type: 'string' },
retain: { type: 'boolean' },
},
required: ['path'],
additionalProperties: false,
},
additionalProperties: false,
},

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8015
layers: { type: 'object' },

/*
* Modes for config validation:
* - error: the error is thrown
Expand Down