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

Allow configuration of underlying HTTP client. #97

Merged
merged 4 commits into from
Jun 21, 2022

Conversation

markylaing
Copy link
Contributor

@markylaing markylaing commented Jun 9, 2022

Allows a user to pass a HTTP client in to the controller, to be used for making requests to the MAAS API. If no HTTP client is provided on controller creation, a new HTTP client is instantiated for each request (this is the same as previous behaviour).

This allows a user to configure TLS between self-signed servers, or to set request timeouts.

The changes are tested by forcing a timeout error on a request to the test server.

@jujubot
Copy link
Contributor

jujubot commented Jun 9, 2022

Can one of the admins verify this patch?

client.go Show resolved Hide resolved
Copy link
Member

@jameinel jameinel left a comment

Choose a reason for hiding this comment

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

I'm ok with the change, it seems a little weird to always copy the http.Client, but it certainly isn't wrong at this point.

client.go Outdated Show resolved Hide resolved
Adds a HTTPClient field containing a *http.Client to the gomaasapi.Client
and uses it for requests if non-nil.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Adds a HTTPClient field to ControllerArgs and sets the client.HTTPClient
to the given value. If no http client is provided, the gomaasapi.Client
will instantiate it's own client per request.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Sets a delay on the test server and a timeout on the HTTP client
provided to the client such that a timeout is forced. Asserts that
the returned error is a context deadline exceeded.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
@markylaing markylaing force-pushed the configurable-http-client branch from dd8bf9f to c66030f Compare June 16, 2022 08:29
@jameinel
Copy link
Member

/build

1 similar comment
@jameinel
Copy link
Member

/build

@jameinel
Copy link
Member

/merge

1 similar comment
@jameinel
Copy link
Member

/merge

@jujubot jujubot merged commit 1ee6817 into juju:v2 Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants