-
Notifications
You must be signed in to change notification settings - Fork 330
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
Adds the ability to use a proxy, Closes #2698 #4679
Conversation
Nice work, we'll review it ASAP! |
9c7c16f
to
76a3075
Compare
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.
Almost there! Let's do a couple more adjustments and clarify the use of ports vs. protocols.
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.
Almost there! Let's do a couple more adjustments and clarify the use of ports vs. protocols.
Thank you for the review @waldekmastykarz, the PR is updated! Can you take another look? |
Will do 👍 |
8eeaa1c
to
9ee9952
Compare
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.
Hey @nicodecleyre, sorry for late reply. Following our discussion and like suggested here: #2698 (comment), let's align with the common convention for Node.js apps and use the standard environment variables HTTP_PROXY and HTTPS_PROXY instead of introducing our own setting. That will make it more consistent with other Node.js apps and make the CLI more intuitive to use for folks who use Node.js.
Hey @waldekmastykarz, would be a nice change if we could use the environment variables. A couple of months ago I did some research on this but wasn't able to find how to get this working in all interfaces/environments. Do you know by any chance if there is a call for these environment variables across all interfaces/environments? |
Not sure what you mean with "across all interfaces/environments". Could you please elaborate @nicodecleyre? Also, looking at the PR once again, I realized that we haven't added support for proxying application insights calls, which has its own proxy setup. We've changed how telemetry is run #5327 but haven't merged it yet, so let's so let's ensure that we include the necessary changes there as well when we process this PR. |
Hi @waldekmastykarz, what I mean with "across all interfaces/environments" is how do we ensure that we can retrieve the value of these environment variables in:
as per my knowledge, you can set a env var in cmd like this: No offense intended, but you said here that setting environment variable differs per shell and you don't think we can do anything about it. So i'm having a bit of a feeling that we're having the same discussion again 😄 I've looked at the PR, but I don't quite understand what you mean with "support for proxying application insights calls", can you elaborate what you expect for this in this PR? |
7d92a27
to
1eea5b2
Compare
Check, so with "environments" you mean "shells", understood.
While setting environment variables differs per shell like we discussed, it shouldn't be relevant to us because we only care about reading their value, which should be standardized and available through
In CLI for Microsoft 365 we use Application Insights to track telemetry. Application Insights comes with its own instrumentation for proxy and this PR should pass the proxy configuration to Application Insights too. In its current state, if the user set a proxy on their machine, our telemetry collection would not work. |
Hi @waldekmastykarz, I've included the telemetry changes from the PR you provided. But it keeps failing on 3 tests, can i get some guidance on this please? |
Sure thing! Let me have a look |
Hey @nicodecleyre, is your branch still up to date? I'm seeing some odd changes as a part of the PR that don't seem to be related and seem like something that might've been pulled in? Could you please double check before we continue the review? Thanks! |
Hi @waldekmastykarz, I took the telemetry changes from the pr #5327 which isn't merged yet, as you asked. But maybe I misunderstood what you were trying to say? |
Ah sorry, right. That got me confused. I thought we've already merged #5327 which isn't the case. All good. |
Hey @nicodecleyre, now that we've merged #5327, could you please do one final rebase so that we can review your proposed changes and get them in? Thanks again for your patience 😊 |
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.
Hey @nicodecleyre, when I rebase your PR onto the latest main, I'm getting 2 test failing:
Could you please have a look at what's wrong? I confirmed that these tests only fail after rebasing your PR. If I get latest from main, all tests pass and I get 100% coverage.
bf7410a
to
0140636
Compare
Hi @waldekmastykarz, rebase done ✅ |
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.
Almost there. Let's do a few more adjustments before we merge it
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.
Very nicely done with a few cosmetic changes I've added when merging the PR 👏
@@ -396,10 +396,14 @@ describe('Request', () => { | |||
}); | |||
|
|||
it('returns response of a successful GET request, with a proxy url', (done) => { | |||
let outcome = 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.
It would be clearer to name the variable after what it represents, eg. proxyConfigured
sinon.stub(process, 'env').value({ 'HTTPS_PROXY': 'http://proxy.contoso.com:8080' }); | ||
|
||
sinon.stub(_request as any, 'req').callsFake((options) => { | ||
_options = options as CliRequestOptions; | ||
if (_options.proxy && _options.proxy.host === 'proxy.contoso.com' && _options.proxy.port === 8080 && _options.proxy.protocol === 'http') { |
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 can simplify this code by assigning the outcome of the comparison directly to the proxyConfigured
variable without an if
sinon.stub(process, 'env').value({ 'HTTPS_PROXY': 'http://username:password@proxy.contoso.com:8080' }); | ||
|
||
sinon.stub(_request as any, 'req').callsFake((options) => { | ||
_options = options as CliRequestOptions; | ||
if (_options.proxy && _options.proxy.host === 'proxy.contoso.com' | ||
&& _options.proxy.port === 8080 |
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.
Let's put operators at the end of line for readability
@@ -14,6 +14,7 @@ const settingsNames = { | |||
printErrorsAsPlainText: 'printErrorsAsPlainText', | |||
prompt: 'prompt', | |||
promptListPageSize: 'promptListPageSize', | |||
proxyUrl: 'proxyUrl', |
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 should remove it since we're not using it
Merged manually. Thank you! 👏 |
Closes #2698