The API decodeBody function will now check the content length
before attempting to decode. If the length is zero, and the out
interface is nil then it is safe to assume the API call is not
returning any data to the user. This allows us to better handle
passing nil to API calls in a single place.
If a websocket connection errors we currently return the error with a
copy of the response body. The response body from the websocket can
often times be completely illegible so remove it from the error string.
make alloc id empty for more reliable failure
un-gzip if content encoding header present
Jobs can be created with user-provided IDs containing any character
except spaces. The jobId needs to be escaped when used in a request
path, otherwise jobs created with names such as "why?" can't be managed
after they are created.
`*Config.ConfigureTLS()` is invoked internally by `NewClient` and API
consumers should not invoke directly.
Now that http client is created in `api.NewClient`,
`*Config.ConfigureTLS` makes no sense. API consumers that call it
explicitly can remove the invocation and preserve the behavior.
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`.
Adds nomad exec support in our API, by hitting the websocket endpoint.
We introduce API structs that correspond to the drivers streaming exec structs.
For creating the websocket connection, we reuse the transport setting from api
http client.
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
Fixes#3013
It's a little weird that Client now has a method for returning a
NewClient, but it's a convenient way to dedupe the logic to
connect-directly-to-a-node which is nontrivial and had sutble
differences between locations.
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
In order to authenticate against protected endpoints, e.g.
```
export NOMAD_ADDR=https://$USER:$PASSWORD@nomad.example.net
nomad status
```
Instead of adding username and password to `api.Config`, this is a
rather simple change to the request handler code that passes along any
basic auth information.
* Reverted changes to get methods
* Added prefix query parameter
* Updated node status to use prefix based searching
* Fixed tests
* Removed truncation logic