Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

Make request timeout and TLS properties configurable.#122

Merged
oppegard merged 8 commits intowavefrontHQ:masterfrom
suprajanarasimhan:expose-timeout-and-tls-config
Jan 24, 2023
Merged

Make request timeout and TLS properties configurable.#122
oppegard merged 8 commits intowavefrontHQ:masterfrom
suprajanarasimhan:expose-timeout-and-tls-config

Conversation

@suprajanarasimhan
Copy link
Copy Markdown
Contributor

@suprajanarasimhan suprajanarasimhan commented Nov 3, 2022

Related to #6.
This is an extension of PR #111, which I closed due to having introduced undesired merge commits in git history.

Detailed description:
Make request timeout and TLS properties configurable.

Add new configuration options to README.

Signed-off-by: Devon Warshaw warshawd@vmware.com
Signed-off-by: Jeanette Booher jbooher@vmware.com
Signed-off-by: Supraja Narasimhan suprajan@vmware.com

@suprajanarasimhan
Copy link
Copy Markdown
Contributor Author

Hi @oppegard and @LukeWinikates, this PR is an extension of #111 with a cleaner git history. I explained the decision to create this PR in this comment in #111. Thank you for helping me through this as I learn.

@jbooherl jbooherl requested a review from keep94 November 15, 2022 18:08
@suprajanarasimhan
Copy link
Copy Markdown
Contributor Author

Hello @keep94, nice to meet you! Thank you for taking the time to review -- I will start addressing these today.

@suprajanarasimhan suprajanarasimhan force-pushed the expose-timeout-and-tls-config branch 2 times, most recently from 5f4afcd to d091daf Compare December 2, 2022 18:02
Add new configuration options to README.

  Signed-off-by: Devon Warshaw <warshawd@vmware.com>
  Signed-off-by: Jeanette Booher <jbooher@vmware.com>
  Signed-off-by: Supraja Narasimhan <suprajan@vmware.com>
@suprajanarasimhan suprajanarasimhan force-pushed the expose-timeout-and-tls-config branch from d091daf to 1609951 Compare December 2, 2022 19:14
…ional arguments.

Signed-off-by: Devon Warshaw <warshawd@vmware.com>
Signed-off-by: Devon Warshaw <warshawd@vmware.com>
@suprajanarasimhan
Copy link
Copy Markdown
Contributor Author

Hello @keep94, nice to meet you! Thank you for taking the time to review -- I will start addressing these today.

I made the changes and left the comments open so you can decide if they can be resolved. Thank you!

Copy link
Copy Markdown
Contributor

@keep94 keep94 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes and the great work. I had one more comment. Have to go, so I'll look over it again on Monday.

warshawd and others added 2 commits December 7, 2022 16:37
Signed-off-by: Supraja Narasimhan <suprajanarasimhan@vmware.com>
Signed-off-by: Supraja Narasimhan <suprajanarasimhan@vmware.com>
@suprajanarasimhan suprajanarasimhan force-pushed the expose-timeout-and-tls-config branch from 4590e5c to fc91280 Compare December 8, 2022 19:21
func NewClient(timeout time.Duration, tlsConfig *tls.Config) *http.Client {
var client *http.Client
if tlsConfig == nil {
client = &http.Client{Timeout: timeout}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could simplify this function like so:

if tlsConfig == nil {
    return &http.Client{Timeout: timeout}
}
transport := &http.Transport{TLSClientConfig: tlsConfig}
return &http.Client{Timeout: timeout, Transport: transport}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused by the change as-is @suprajanarasimhan:

	if tlsConfig == nil {
		client = &http.Client{Timeout: timeout}
	}		
	transport := &http.Transport{TLSClientConfig: tlsConfig}
	client = &http.Client{Timeout: timeout, Transport: transport}

    return client

The if condition will have no effect on client since it's overwritten below that. Did you mean to follow Travis' original suggestion?

if tlsConfig == nil {
    return &http.Client{Timeout: timeout}
}
transport := &http.Transport{TLSClientConfig: tlsConfig}
return &http.Client{Timeout: timeout, Transport: transport}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@suprajanarasimhan, can we add test coverage with a nil and non-nil tlsConfig, to catch this logic error?

Copy link
Copy Markdown
Contributor

@keep94 keep94 Jan 13, 2023

Choose a reason for hiding this comment

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

Yes, oppegard is right. When tlsConfig == nil you want to return &http.Client{Timeout: timeout}

Copy link
Copy Markdown
Contributor

@keep94 keep94 Jan 13, 2023

Choose a reason for hiding this comment

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

As oppegard already stated, consider adding a test for internal.NewClient(). When the tlsConfig parameter is nil, the Transport field of returned http client should be nil.

Copy link
Copy Markdown
Contributor Author

@suprajanarasimhan suprajanarasimhan Jan 20, 2023

Choose a reason for hiding this comment

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

Hi @oppegard, thank for catching this logic error! 🙏🏽 @ktollivervmw, @jessepye and I added the test you and @keep94 recommended. Grateful for both of your thorough and informative reviews.

@suprajanarasimhan
Copy link
Copy Markdown
Contributor Author

Hello @keep94! Coming back to this after the holidays and I made the changes you requested.

Overall, your feedback exposed me to concepts and code style that I can try to apply in the future, too! I really appreciate it. 🙏🏽

@keep94
Copy link
Copy Markdown
Contributor

keep94 commented Jan 11, 2023

I will have time Friday afternoon to take a look. Is that ok?

@suprajanarasimhan
Copy link
Copy Markdown
Contributor Author

I will revisit this feedback later today -- thank you!

Signed-off-by: Kyle Tolliver <ktolliver@vmware.com>
Copy link
Copy Markdown
Contributor

@oppegard oppegard left a comment

Choose a reason for hiding this comment

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

lgtm

@oppegard oppegard merged commit 45f78be into wavefrontHQ:master Jan 24, 2023
@suprajanarasimhan suprajanarasimhan deleted the expose-timeout-and-tls-config branch August 2, 2023 23:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants