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

Fix for lambda not evaluating some environment variables #42

Merged
merged 1 commit into from
Apr 10, 2023
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
6 changes: 3 additions & 3 deletions src/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ async function getEventArguments(event) {
event['width'] = DEFAULT_WIDTH;
if (event.height === undefined)
event['height'] = DEFAULT_MIN_HEIGHT;
if (event.filename === undefined)
if (event.filename === undefined && process.env[ENV_VAR.FILENAME] === undefined)
event['filename'] = DEFAULT_FILENAME;
if (event.subject === undefined)
if (event.subject === undefined && process.env[ENV_VAR.EMAIL_SUBJECT] === undefined)
event['subject'] = DEFAULT_EMAIL_SUBJECT;
if (event.note === undefined)
if (event.note === undefined && process.env[ENV_VAR.EMAIL_NOTE] === undefined)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works but seems backwards, it's easy to miss since the code is checking process.env[ENV_VAR.EMAIL_NOTE] in both getOptions and getEventArguments. e.g. if a config file is introduced later, this needs to also check && config_file.email_note === undefined

i think peter brought this up before, it might be better to have a default options object in getOptions. If there are any explicitly defined configs, overwrite the value with the highest priority config (command arguments > environment variables), or overwrite multiple times starting from lowest priority

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. will need check how to set default options object though because currently for cli options object is created with commander program, even setting env var is happening at that time for cli https://github.com/opensearch-project/reporting-cli/blob/main/src/arguments.js#L24 and want to keep main logic same for cli/lambda/package. getOptions is setting environment variable only for lambda & credentials as it has :. Anyway will add this also to refactor issue and try to prioritize.

event['note'] = DEFAULT_EMAIL_NOTE;
if (event.multitenancy === undefined)
event['multitenancy'] = DEFAULT_MULTI_TENANCY;
Expand Down