Copy Consul API's format: QueryOptions.WithContext(context) will now return
a new QueryOption whose HTTP requests will be canceled with the context
provided (and similar for WriteOptions)
Allow clients to configure httpClient, e.g. set a pooled/keep-alive
client.
When caller configures HttpClient explicitly, we aim to use as-is; e.g.
we assume it's configured with TLS already. Expose `ConfigureTLS` to
aid api consumers with configuring their http client.
Also, removes `SetTimeout` call that I believe is internal only and has
odd side-effects when called on already created config. Also deprecates
`config.ConfigureTLS` in preference to the new `ConfigureTLS`.
* Divest api/ package of deps elsewhere in the nomad repo.
This will allow making api/ a module without then pulling in the
external repo, leading to a package name conflict.
This required some migration of tests to an apitests/ folder (can be
moved anywhere as it has no deps on it). It also required some
duplication of code, notably some test helpers from api/ -> apitests/
and part (but not all) of testutil/ -> api/testutil/.
Once there's more separation and an e.g. sdk/ folder those can be
removed in favor of a dep on the sdk/ folder, provided the sdk/ folder
doesn't depend on api/ or /.
* Also remove consul dep from api/ package
* Fix stupid linters
* Some restructuring
This PR enhances the API package by having client only RPCs route
through the server when they are low cost and for filesystem access to
first attempt a direct connection to the node and then falling back to
a server routed request.
This PR fixes the construction of the TLSServerName when connecting to a
node that has TLS enabled and adds tests for all possible permutations.
Fixes https://github.com/hashicorp/nomad/issues/3013
The format of the missing port error message changed from Go 1.7 to 1.8.
The fix is to just use strings.Contains instead of strings.HasPrefix
when looking for the "missing port" part.
Also add an error return to Client.newRequest as parsing the path
processes arbitrary user input and would panic if given an invalid URL.
See: https://groups.google.com/d/topic/nomad-tool/gi3-CTE7oXo/discussion