diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-11-20 14:04:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-20 14:04:06 +0100 |
commit | 4808368505e8ab5b69a46558e2868fb819aee46b (patch) | |
tree | 36604e1d77b2cab0fc65d4e71d6c6ffbfb5a510e | |
parent | e8c0a04b67b632ea3f98327d8f39cd0293ad8581 (diff) | |
parent | 50054b735286f2a820a26a36bb10c35988351722 (diff) |
Merge pull request #29382 from vespa-engine/mpolden/avoid-tls-reconfig-for-feed
Avoid reconfiguring TLS when a custom client is used
-rw-r--r-- | client/go/internal/vespa/target.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/client/go/internal/vespa/target.go b/client/go/internal/vespa/target.go index 8c3f5c9b7c3..f3a94f762ff 100644 --- a/client/go/internal/vespa/target.go +++ b/client/go/internal/vespa/target.go @@ -9,7 +9,6 @@ import ( "io" "net/http" "strings" - "sync" "time" "github.com/vespa-engine/vespa/client/go/internal/util" @@ -51,9 +50,9 @@ type Service struct { TLSOptions TLSOptions deployAPI bool - once sync.Once auth Authenticator httpClient util.HTTPClient + customClient bool retryInterval time.Duration } @@ -109,7 +108,10 @@ type LogOptions struct { // Do sends request to this service. Authentication of the request happens automatically. func (s *Service) Do(request *http.Request, timeout time.Duration) (*http.Response, error) { - util.ConfigureTLS(s.httpClient, s.TLSOptions.KeyPair, s.TLSOptions.CACertificate, s.TLSOptions.TrustAll) + if !s.customClient { + // Do not override TLS config if a custom client has been configured + util.ConfigureTLS(s.httpClient, s.TLSOptions.KeyPair, s.TLSOptions.CACertificate, s.TLSOptions.TrustAll) + } if s.auth != nil { if err := s.auth.Authenticate(request); err != nil { return nil, fmt.Errorf("%w: %s", errAuth, err) @@ -118,8 +120,11 @@ func (s *Service) Do(request *http.Request, timeout time.Duration) (*http.Respon return s.httpClient.Do(request, timeout) } -// SetClient sets the HTTP client that this service should use. -func (s *Service) SetClient(client util.HTTPClient) { s.httpClient = client } +// SetClient sets a custom HTTP client that this service should use. +func (s *Service) SetClient(client util.HTTPClient) { + s.httpClient = client + s.customClient = true +} // Wait polls the health check of this service until it succeeds or timeout passes. func (s *Service) Wait(timeout time.Duration) error { |