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

Change init of consul client to respect TLS #348

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Changelog

* [CHANGE] Change initialisation of consul client to respect TLS specific environemnt variables. #345
* [CHANGE] Change `WaitRingStability` and `WaitInstanceState` methods signature to rely on `ReadRing` instead. #251
* [CHANGE] Added new `-consul.cas-retry-delay` flag. It has a default value of `1s`, while previously there was no delay between retries. #178
* [CHANGE] Flagext: `DayValue` now always uses UTC when parsing or displaying dates. #71
Expand Down
21 changes: 10 additions & 11 deletions kv/consul/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"flag"
"fmt"
"math/rand"
"net/http"
"time"

"github.com/go-kit/log"
Expand Down Expand Up @@ -84,16 +83,16 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet, prefix string) {

// NewClient returns a new Client.
func NewClient(cfg Config, codec codec.Codec, logger log.Logger, registerer prometheus.Registerer) (*Client, error) {
client, err := consul.NewClient(&consul.Config{
Address: cfg.Host,
Token: cfg.ACLToken.String(),
Scheme: "http",
HttpClient: &http.Client{
Transport: cleanhttp.DefaultPooledTransport(),
// See https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/
Timeout: cfg.HTTPClientTimeout,
},
})
config := &consul.Config{
Address: cfg.Host,
Token: cfg.ACLToken.String(),
Scheme: "http",
Transport: cleanhttp.DefaultPooledTransport(),
}
client, err := consul.NewClient(config)
// See https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/
config.HttpClient.Timeout = cfg.HTTPClientTimeout

if err != nil {
return nil, err
}
Expand Down