From c40a780f9bbcaa2dd326db6241deff5ed7c6edc4 Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Tue, 23 Mar 2021 11:32:53 +0100 Subject: [PATCH] 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. --- .../pkg/clientbuilder/client_builder_dynamic.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/controller-manager/pkg/clientbuilder/client_builder_dynamic.go b/staging/src/k8s.io/controller-manager/pkg/clientbuilder/client_builder_dynamic.go index 81946198374..c8ceaefecea 100644 --- a/staging/src/k8s.io/controller-manager/pkg/clientbuilder/client_builder_dynamic.go +++ b/staging/src/k8s.io/controller-manager/pkg/clientbuilder/client_builder_dynamic.go @@ -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 }