DynamicControllerClientBuilder: use already provided config when creating new clients

It is the caller's responsibility to remove sensitive information prior to creation.
This allows for potential extensions in the future.
For example, it preserves HTTP wrappers for custom behavior per request.
This commit is contained in:
Lukasz Szaszkiewicz 2021-03-23 11:32:53 +01:00
parent fa118e23ec
commit c40a780f9b

View File

@ -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
}