-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: implement proxy usage #11
Conversation
What is the progress of this PR? I faced the same issue that the binaries can't be downloaded when a proxy is used. |
+1 please merge this |
Hi @BlackDark, apologies for the delay in response. Thank you for the contribution! This looks like a good addition but there are a few things to get sorted first. We had to update openpgp to latest stable in another PR, but that has made conflicting changes for you. Can you please rebase on main and fold those in? It's hard to tell what changes are necessary to get proxy support added when you're reformatted the entire file. Can you please walk back the formatting changes so we can review this PR? |
47db578
to
472f491
Compare
472f491
to
3d16347
Compare
@jpogran Rebased and cleanup up commit |
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.
Minor request not to print proxy details to the console. Going to look into how this library is handling errors versus the presentation here.
src/utils.ts
Outdated
console.log(`Found proxy setting. Using to download files.`); | ||
console.log(`HTTP: ${httpProxy}`); | ||
console.log(`HTTPS: ${httpProxy}`); |
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.
console.log(`Found proxy setting. Using to download files.`); | |
console.log(`HTTP: ${httpProxy}`); | |
console.log(`HTTPS: ${httpProxy}`); |
We shouldn't be printing to the console proxy details
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.
Removed
src/utils.ts
Outdated
url: string, | ||
options: AxiosRequestConfig = {} | ||
): Promise<any> { | ||
console.log(`Request to: ${url} with options: ${JSON.stringify(options)}`); |
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.
console.log(`Request to: ${url} with options: ${JSON.stringify(options)}`); |
We shouldn't be printing to the console proxy details
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.
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.
This is a good question, and is something that has some variance in implementations. In this case we expect the application using this library to output information like this, not the library itself.
Logging information is an important task of any library, but there isn't a way in this library to currently log anything. A future PR could introduce an interface and method overload that allows logging to different targets, but this is out of scope here.
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.
Removed
src/utils.ts
Outdated
console.error(e.toJSON()); | ||
throw new Error(`Request for terraform binary failed: ${e && e.message}`); |
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.
Going to ask internally about the usage for this library, but I think we should follow the previous pattern of the resolve/reject with promises instead of try/catch and printing a message to the console.
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.
Reviewed with the team and we agree the approach here is good with the exception of catching the error here. We shouldn't print the error to the console and throw a new formatted here.
This library is used for more than downloading terraform, so instead we should let the caller handle the exception.
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.
Remove the try catch so the caller must handle the error
Looking good so far. If you could add a short note to the README about the environment variables needed in order to activate this functionality I'd appreciate it. If not I can do that as a follow up. |
Hi @jpogran found some time working on my PR. Updated your comments as suggested and updated the README. |
Thanks a lot for the updates. I noticed one thing when running npm install.
Most of the vulnerabilities are related to dev packages and not part of this PR, but the critical one is. It was introduced by a dependency of Do you mind updating the deps accordingly? |
Updated the dependency :) |
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.
Thank you for contributing this!
Apologies on the delay, merging this now! |
Hey @BlackDark / @jpogran - I've been tracking an annoying deprecation warning I've been seeing in the https://github.com/hashicorp/setup-terraform GitHub Action recently.
This is actually seen in the opening screenshot 😄. Tracking this back, it's been this change that's cause the message:
Got there! I wonder if there is an alternative to the |
@magnetikonline I've created a new issue for request with the content you've posted. We'll look into seeing what can be done about this.. Next time, you can open a new issue and link to the PR in question instead of posting to a closed PR. Not all projects keep tabs on closed PRs. |
Fair call @jpogran - sorry about that. |
Closes #10
Have written small changes for proxy usage.
Tested in my environment where i need a proxy.
Released necessary package and adapted changes to the github action:
Tried using it in an action
Works: