Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Bulat Shakirzyanov <83289+avalanche123@users.noreply.github.com>
  • Loading branch information
avalanche123 committed Sep 13, 2023
1 parent 33077ed commit 34787b1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func ForNamespace(n string) GetOption {
}

// Get a client that uses the specified bearer token.
func (c *Cache) Get(cr auth.Credentials, o ...GetOption) (client.Client, error) {
func (c *Cache) Get(cr auth.Credentials, o ...GetOption) (client.Client, error) { //nolint:gocyclo
opts := &getOptions{}
for _, fn := range o {
fn(opts)
Expand Down Expand Up @@ -257,6 +257,7 @@ func (c *Cache) Get(cr auth.Credentials, o ...GetOption) (client.Client, error)
if err != nil {
return nil, errors.Wrap(err, errNewHTTPClient)
}

caopt := cache.Options{
HTTPClient: hc,
Scheme: c.scheme,
Expand Down Expand Up @@ -298,6 +299,12 @@ func (c *Cache) Get(cr auth.Credentials, o ...GetOption) (client.Client, error)
sn = &session{client: wc, cancel: cancel, expiry: c.expiry, expiration: expiration, log: log}

c.mx.Lock()
// another gorouting might have set the session.
if sn, ok := c.active[id]; ok {
c.mx.Unlock()
log.Debug("Used existing client")
return sn, nil
}
c.active[id] = sn
c.mx.Unlock()

Expand Down

0 comments on commit 34787b1

Please sign in to comment.