mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #99776 from p0lyn0mial/upstream-kcm-dynamic-client-builder
DynamicControllerClientBuilder: allows for plugging HTTP wrappers for custom behaviour
This commit is contained in:
commit
12ed525b63
@ -116,7 +116,7 @@ func (t *DynamicControllerClientBuilder) Config(saName string) (*restclient.Conf
|
||||
|
||||
rt, ok := t.roundTripperFuncMap[saName]
|
||||
if ok {
|
||||
configCopy.WrapTransport = rt
|
||||
configCopy.Wrap(rt)
|
||||
} else {
|
||||
cachedTokenSource := transport.NewCachedTokenSource(&tokenSourceImpl{
|
||||
namespace: t.Namespace,
|
||||
@ -125,7 +125,7 @@ func (t *DynamicControllerClientBuilder) Config(saName string) (*restclient.Conf
|
||||
expirationSeconds: t.expirationSeconds,
|
||||
leewayPercent: t.leewayPercent,
|
||||
})
|
||||
configCopy.WrapTransport = transport.ResettableTokenSourceWrapTransport(cachedTokenSource)
|
||||
configCopy.Wrap(transport.ResettableTokenSourceWrapTransport(cachedTokenSource))
|
||||
t.roundTripperFuncMap[saName] = configCopy.WrapTransport
|
||||
}
|
||||
|
||||
@ -235,7 +235,11 @@ func (ts *tokenSourceImpl) Token() (*oauth2.Token, error) {
|
||||
|
||||
func constructClient(saNamespace, saName string, config *restclient.Config) restclient.Config {
|
||||
username := apiserverserviceaccount.MakeUsername(saNamespace, saName)
|
||||
ret := *restclient.AnonymousClientConfig(config)
|
||||
// make a shallow copy
|
||||
// the caller already castrated the config during creation
|
||||
// this allows for potential extensions in the future
|
||||
// for example it preserve HTTP wrappers for custom behavior per request
|
||||
ret := *config
|
||||
restclient.AddUserAgent(&ret, username)
|
||||
return ret
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user