Consul watch ignores HTTP API Options on command line
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 43
Description
#### Overview of the Issue
`consul watch` command doesn't pass down HTTP flags (args) down to watch plan.
https://github.com/hashicorp/consul/blob/master/command/watch/watch.go#L252 passes a nil config down which causes the watch plan to re-create a NewClient with mostly default options, while the HTTP options from https://github.com/hashicorp/consul/blob/master/command/watch/watch.go#L162 get discarded.
Using environment variables for the HTTP options still works since the new re-created Client in plan.go will parse those upon creation.
#### Reproduction Steps
Run consul with a self signed certificate and a custom CA file.
```
~# consul watch -http-addr https://consul-server-addr:8443 -type nodes
Error querying Consul agent: Get https://consul-server-addr:8443/v1/agent/self: x509: certificate signed by unknown authority
~# consul watch -ca-file /etc/consul.d/ca.crt -http-addr https://consul-server-addr:8443 -type nodes
2019/12/11 00:16:14 [ERR] consul.watch: Watch (type: nodes) errored: Get https://consul-server-addr:8443/v1/catalog/nodes: x509: certificate signed by unknown authority, retry in 5s
^C
~# env CONSUL_CACERT=/etc/consul.d/ca.crt consul watch -http-addr https://consul-server-addr:8443 -type nodes
[
{
"ID": "f75216c7-d78a-5757-xxxx-346e0a4b64b8",
...
```
Contributor guide
Assessment
This issue has not been assessed yet.