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

Add HTTP User-Agent header to all requests in SDK #336

Merged
merged 6 commits into from
Oct 7, 2020

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented Oct 2, 2020

This PR adds default HTTP User-Agent header with value go-vcloud-director. It also adds the capability to customize (or disable) this value by using WithHttpUserAgent() configuration option for NewVCDClient function.

Note. Testing to ensure that all outgoing requests contain HTTP header is not trivial therefore this library extends util package with an additional flag PanicEmptyUserAgent which would cause panic in ProcessRequestOutput function which is hopefully logging gateway to all current and future HTTP requests. func (vcd *TestVCD) SetUpSuite(check *C) is configured to include verification of it by default.

Tests did pass which means (as per above note) that all logged HTTP calls have the header set.

@Didainius Didainius marked this pull request as ready for review October 3, 2020 02:47
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Contributor

@vbauzys vbauzys left a comment

Choose a reason for hiding this comment

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

LGTM. Have you already tested with terraform?

@Didainius
Copy link
Collaborator Author

LGTM. Have you already tested with terraform?

Yep. vmware/terraform-provider-vcd#566

@Didainius Didainius merged commit 002215c into vmware:master Oct 7, 2020
@Didainius Didainius deleted the user-agent branch October 7, 2020 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants