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