Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 8305bc7

Browse files
authored
fix(index.js): add schema validation (#97)
1 parent 1cc7cf2 commit 8305bc7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/index.js

+45
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,51 @@ export default class ServerlessEpsagonPlugin {
7474
},
7575
};
7676

77+
// Added: Schema based validation of service config
78+
// https://github.com/serverless/serverless/releases/tag/v1.78.0
79+
if (this.sls.configSchemaHandler) {
80+
const newCustomPropSchema = {
81+
type: 'object',
82+
properties: {
83+
epsagon: {
84+
type: 'object',
85+
properties: {
86+
token: { type: 'string' },
87+
appName: { type: 'string' },
88+
disable: { type: 'boolean' },
89+
metadataOnly: { type: 'boolean' },
90+
handlersDirName: { type: 'string' },
91+
packageJsonPath: { type: 'string' },
92+
collectorURL: { type: 'string' },
93+
ignoredKeys: { type: 'string' },
94+
urlsToIgnore: { type: 'string' },
95+
labels: { type: 'string' },
96+
},
97+
additionalProperties: false,
98+
},
99+
},
100+
};
101+
this.sls.configSchemaHandler.defineCustomProperties(newCustomPropSchema);
102+
103+
// Added: defineFunctionProperties schema extension method
104+
// https://github.com/serverless/serverless/releases/tag/v2.10.0
105+
if (this.sls.configSchemaHandler.defineFunctionProperties) {
106+
this.sls.configSchemaHandler.defineFunctionProperties('aws', {
107+
properties: {
108+
epsagon: {
109+
type: 'object',
110+
properties: {
111+
appName: { type: 'string' },
112+
disable: { type: 'boolean' },
113+
wrapper: { type: 'string' },
114+
},
115+
additionalProperties: false,
116+
},
117+
},
118+
});
119+
}
120+
}
121+
77122
this.hooks = {
78123
'after:package:initialize': this.run.bind(this),
79124
'before:deploy:function:packageFunction': this.run.bind(this),

0 commit comments

Comments
 (0)