mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +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]
|
rt, ok := t.roundTripperFuncMap[saName]
|
||||||
if ok {
|
if ok {
|
||||||
configCopy.WrapTransport = rt
|
configCopy.Wrap(rt)
|
||||||
} else {
|
} else {
|
||||||
cachedTokenSource := transport.NewCachedTokenSource(&tokenSourceImpl{
|
cachedTokenSource := transport.NewCachedTokenSource(&tokenSourceImpl{
|
||||||
namespace: t.Namespace,
|
namespace: t.Namespace,
|
||||||
@ -125,7 +125,7 @@ func (t *DynamicControllerClientBuilder) Config(saName string) (*restclient.Conf
|
|||||||
expirationSeconds: t.expirationSeconds,
|
expirationSeconds: t.expirationSeconds,
|
||||||
leewayPercent: t.leewayPercent,
|
leewayPercent: t.leewayPercent,
|
||||||
})
|
})
|
||||||
configCopy.WrapTransport = transport.ResettableTokenSourceWrapTransport(cachedTokenSource)
|
configCopy.Wrap(transport.ResettableTokenSourceWrapTransport(cachedTokenSource))
|
||||||
t.roundTripperFuncMap[saName] = configCopy.WrapTransport
|
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 {
|
func constructClient(saNamespace, saName string, config *restclient.Config) restclient.Config {
|
||||||
username := apiserverserviceaccount.MakeUsername(saNamespace, saName)
|
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)
|
restclient.AddUserAgent(&ret, username)
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user