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

Fix: Override configs with function-level params #100

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ export default class ServerlessEpsagonPlugin {
// eslint-disable-next-line no-param-reassign
func.epsagon.wrapper = this.config().wrapper;
}
const handlerCode = generateWrapperCode(func, this.config());

const handlerCode = generateWrapperCode(func, this.config({
funcName: func.key,
}));
await writeFile(
join(
handlersFullDirPath,
Expand Down Expand Up @@ -303,11 +306,17 @@ export default class ServerlessEpsagonPlugin {
* Gets the plugin config.
* @returns {Object} The config object
*/
config() {
return Object.assign({
config({ funcName = '' } = {}) {
const funcs = this.sls.service.functions || {};
const funcConfig = (funcs[funcName] || {}).epsagon || {};
const epsagonConfig = (this.sls.service.custom || {}).epsagon || {};

return {
metadataOnly: 'false',
handlersDirName: 'epsagon_handlers',
}, (this.sls.service.custom || {}).epsagon || {});
...epsagonConfig,
...funcConfig,
};
}

/**
Expand Down