-
Notifications
You must be signed in to change notification settings - Fork 140
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
add proxy support using hpagent #374
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
"homepage": "https://github.com/hashicorp/vault-action#readme", | ||
"dependencies": { | ||
"got": "^11.8.5", | ||
"hpagent": "^1.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the latest version is 1.2.0 if we want to start with an up-to-date new dependency |
||
"jsonata": "^1.8.6", | ||
"jsrsasign": "^10.5.25" | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
const core = require('@actions/core'); | ||
const command = require('@actions/core/lib/command'); | ||
const got = require('got').default; | ||
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent'); | ||
const jsonata = require('jsonata'); | ||
const { auth: { retrieveToken }, secrets: { getSecrets } } = require('./index'); | ||
|
||
|
@@ -27,6 +28,7 @@ async function exportSecrets() { | |
prefixUrl: vaultUrl, | ||
headers: {}, | ||
https: {}, | ||
agent: {}, | ||
retry: { | ||
statusCodes: [ | ||
...got.defaults.options.retry.statusCodes, | ||
|
@@ -37,6 +39,26 @@ async function exportSecrets() { | |
} | ||
} | ||
|
||
if (process.env['http_proxy'] || process.env['HTTP_PROXY']) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add this setting in the list of inputs supported by the action so it is explicit and documented. Unless these environment variables have a special meaning and are required for the agent to work properly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are pretty standard environment variables that, if needed, could be added to the When using this action on github.com, these variables would not be set and would not be needed. They are only necessary in a corporate environment where network "compartments" might require a proxy to be configured in order to reach them. That's why I did not add them as inputs, but rather just made the decision to pick them up from the runner's environment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it make sense since they are standard, not vault-specific and the use case is somewhat niche. It's probably worth a mention in the README though, otherwise people would need to read the source code to know proxy servers are supported by the action. |
||
defaultOptions.agent.http = new HttpProxyAgent({ | ||
keepAlive: true, | ||
keepAliveMsecs: 1000, | ||
maxSockets: 256, | ||
maxFreeSockets: 256, | ||
proxy: process.env['http_proxy'] || process.env['HTTP_PROXY'] | ||
}) | ||
} | ||
|
||
if (process.env['https_proxy'] || process.env['HTTPS_PROXY']) { | ||
defaultOptions.agent.https = new HttpsProxyAgent({ | ||
keepAlive: true, | ||
keepAliveMsecs: 1000, | ||
maxSockets: 256, | ||
maxFreeSockets: 256, | ||
proxy: process.env['https_proxy'] || process.env['HTTPS_PROXY'] | ||
}) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand this might be very difficult to test functionally but can we add a small UT that at least checks the agent is set or unset depending of the config received? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will see what I can do! |
||
|
||
const tlsSkipVerify = (core.getInput('tlsSkipVerify', { required: false }) || 'false').toLowerCase() != 'false'; | ||
if (tlsSkipVerify === true) { | ||
defaultOptions.https.rejectUnauthorized = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generate the dist/index when releasing new versions its fine to not commit it if you prefer. It often leads to annoying merge conflicts to resolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about that part... whether it needed to be added to the commit or not. I can definitely remove it.