mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Allow providing wrapper for client config
This commit is contained in:
parent
3b76c75831
commit
c5aea015c3
@ -388,6 +388,12 @@ func (f *ConfigFlags) WithDiscoveryBurst(discoveryBurst int) *ConfigFlags {
|
||||
return f
|
||||
}
|
||||
|
||||
// WithWrapConfigFn allows providing a wrapper function for the client Config.
|
||||
func (f *ConfigFlags) WithWrapConfigFn(wrapConfigFn func(*rest.Config) *rest.Config) *ConfigFlags {
|
||||
f.WrapConfigFn = wrapConfigFn
|
||||
return f
|
||||
}
|
||||
|
||||
// NewConfigFlags returns ConfigFlags with default values set
|
||||
func NewConfigFlags(usePersistentConfig bool) *ConfigFlags {
|
||||
impersonateGroup := []string{}
|
||||
|
@ -433,8 +433,12 @@ func addCmdHeaderHooks(cmds *cobra.Command, kubeConfigFlags *genericclioptions.C
|
||||
crt.ParseCommandHeaders(cmd, args)
|
||||
return existingPreRunE(cmd, args)
|
||||
}
|
||||
wrapConfigFn := kubeConfigFlags.WrapConfigFn
|
||||
// Wraps CommandHeaderRoundTripper around standard RoundTripper.
|
||||
kubeConfigFlags.WrapConfigFn = func(c *rest.Config) *rest.Config {
|
||||
if wrapConfigFn != nil {
|
||||
c = wrapConfigFn(c)
|
||||
}
|
||||
c.Wrap(func(rt http.RoundTripper) http.RoundTripper {
|
||||
// Must be separate RoundTripper; not "crt" closure.
|
||||
// Fixes: https://github.com/kubernetes/kubectl/issues/1098
|
||||
|
Loading…
Reference in New Issue
Block a user