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

Commit 82405ac

Browse files
authored
fix(index): override function configs with their function-level params (#100)
Authored-by: ronnathaniel <ronnathaniel>
1 parent 57d60da commit 82405ac

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ export default class ServerlessEpsagonPlugin {
263263
// eslint-disable-next-line no-param-reassign
264264
func.epsagon.wrapper = this.config().wrapper;
265265
}
266-
const handlerCode = generateWrapperCode(func, this.config());
266+
267+
const handlerCode = generateWrapperCode(func, this.config({
268+
funcName: func.key,
269+
}));
267270
await writeFile(
268271
join(
269272
handlersFullDirPath,
@@ -303,11 +306,17 @@ export default class ServerlessEpsagonPlugin {
303306
* Gets the plugin config.
304307
* @returns {Object} The config object
305308
*/
306-
config() {
307-
return Object.assign({
309+
config({ funcName = '' } = {}) {
310+
const funcs = this.sls.service.functions || {};
311+
const funcConfig = (funcs[funcName] || {}).epsagon || {};
312+
const epsagonConfig = (this.sls.service.custom || {}).epsagon || {};
313+
314+
return {
308315
metadataOnly: 'false',
309316
handlersDirName: 'epsagon_handlers',
310-
}, (this.sls.service.custom || {}).epsagon || {});
317+
...epsagonConfig,
318+
...funcConfig,
319+
};
311320
}
312321

313322
/**

0 commit comments

Comments
 (0)