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

update request options to add keys from config map data to headers #334

Merged
merged 7 commits into from
Aug 12, 2022

Conversation

kdai7
Copy link
Contributor

@kdai7 kdai7 commented Aug 11, 2022

No description provided.

@kdai7 kdai7 requested review from adamkingit and alewitt2 August 11, 2022 18:18
lib/ReqOpts.js Outdated Show resolved Hide resolved
@kdai7 kdai7 requested a review from alewitt2 August 11, 2022 19:14
lib/FetchEnvs.js Outdated Show resolved Hide resolved
@kdai7 kdai7 requested a review from alewitt2 August 12, 2022 13:43
Comment on lines 200 to 210
let reqopt = new FetchEnvs(this);
let headersFrom = objectPath.get(requestOptions, 'headersFrom');
if (headersFrom) {
let headersFromTemp = await reqopt.processEnvFrom(headersFrom);
let headers = objectPath.get(requestOptions, 'headers');
for (const header of headersFromTemp) {
const data = header?.data;
headers = { ...headers, ...data };
}
requestOptions = { ...requestOptions, headers };
}
Copy link
Member

Choose a reason for hiding this comment

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

  • good to use const instead of let where possible.
  • headers was already defined above, use a new name to be clear what the intention is.
  • note: the below suggestion is untested, so make sure it works before just accepting any changes.
Suggested change
let reqopt = new FetchEnvs(this);
let headersFrom = objectPath.get(requestOptions, 'headersFrom');
if (headersFrom) {
let headersFromTemp = await reqopt.processEnvFrom(headersFrom);
let headers = objectPath.get(requestOptions, 'headers');
for (const header of headersFromTemp) {
const data = header?.data;
headers = { ...headers, ...data };
}
requestOptions = { ...requestOptions, headers };
}
const reqopt = new FetchEnvs(this);
const headersFrom = objectPath.get(requestOptions, 'headersFrom');
if (headersFrom) {
const headersFromTemp = await reqopt.processEnvFrom(headersFrom);
let mergedHeaders = { ...headers };
for (const header of headersFromTemp) {
const data = header?.data;
mergedHeaders = { ...mergedHeaders, ...data };
}
requestOptions = { ...requestOptions, headers: mergedHeaders };
}

@kdai7 kdai7 requested a review from alewitt2 August 12, 2022 17:04
@kdai7 kdai7 merged commit 302db9c into master Aug 12, 2022
@kdai7 kdai7 deleted the kdai7 branch August 12, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants