forked from serverless/serverless
/
configSchema.js
144 lines (134 loc) · 4.24 KB
/
configSchema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict';
const functionNamePattern = '^[a-zA-Z0-9-_]+$';
const schema = {
type: 'object',
properties: {
service: {
type: 'object',
properties: {
name: { pattern: '^[a-zA-Z][0-9a-zA-Z-]+$' },
awsKmsKeyArn: { $ref: '#/definitions/awsKmsArn' },
},
additionalProperties: false,
},
frameworkVersion: { type: 'string' },
disabledDeprecations: {
anyOf: [
{ const: '*' },
{ $ref: '#/definitions/errorCode' },
{
type: 'array',
items: { $ref: '#/definitions/errorCode' },
},
],
},
enableLocalInstallationFallback: { type: 'boolean' },
custom: {
type: 'object',
properties: {},
required: [],
// User is free to add any properties for its own purpose
},
plugins: {
anyOf: [
{
type: 'object',
properties: {
localPath: { type: 'string' },
modules: { type: 'array', items: { type: 'string' } },
},
additionalProperties: false,
required: ['modules'],
},
{ type: 'array', items: { type: 'string' } },
],
},
functions: {
type: 'object',
patternProperties: {
[functionNamePattern]: {
type: 'object',
properties: {
name: { type: 'string' }, // name property is added by service class
events: {
type: 'array',
items: {
/*
* `anyOf` array by JSON schema spec cannot be empty, threfore we start
* with one dummy item as workaround to ensure it validates against
* any undefined function events.
*/
anyOf: [
{
type: 'object',
properties: { __schemaWorkaround__: { const: null } },
required: ['__schemaWorkaround__'],
additionalProperties: false,
},
],
},
},
},
/*
* Schema for function properties is extended by a provider plugin.
* For example, in the context of AWS provider props like
* provisionedConcurrency, memorySize, reservedConcurrency, etc.
* should be extended by awsProvider plugin.
*/
additionalProperties: false,
},
},
additionalProperties: false,
},
/*
* Provider specific properties are extended in respected provider plugins.
*/
provider: {
type: 'object',
properties: {},
required: ['name'],
additionalProperties: false,
},
package: {
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: false,
},
// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8015
layers: { type: 'object' },
/*
* Modes for config validation:
* - error: the error is thrown
* - warn: logs error to console without throwing an error
* - off: disables validation at all
*
* The default is `warn`, and will be set to `error` in v2
*/
configValidationMode: { enum: ['error', 'warn', 'off'] },
},
additionalProperties: false,
required: ['provider', 'service'],
definitions: {
// TODO: awsKmsArn definition to be moved to lib/plugins/aws/provider/awsProvider.js once service.awsKmsKeyArn removed with v2.0.0, see https://github.com/serverless/serverless/issues/8261
// TODO: awsKmsArn to include #/definitions/awsCfFunction instead of type: object as one of the possible definition, see https://github.com/serverless/serverless/issues/8261
awsKmsArn: {
anyOf: [{ type: 'object' }, { type: 'string', pattern: '^arn:aws[a-z-]*:kms' }],
},
errorCode: {
type: 'string',
pattern: '^[A-Z0-9_]+$',
},
functionName: {
type: 'string',
pattern: functionNamePattern,
},
},
};
module.exports = schema;