mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +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
|
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
|
// NewConfigFlags returns ConfigFlags with default values set
|
||||||
func NewConfigFlags(usePersistentConfig bool) *ConfigFlags {
|
func NewConfigFlags(usePersistentConfig bool) *ConfigFlags {
|
||||||
impersonateGroup := []string{}
|
impersonateGroup := []string{}
|
||||||
|
@ -433,8 +433,12 @@ func addCmdHeaderHooks(cmds *cobra.Command, kubeConfigFlags *genericclioptions.C
|
|||||||
crt.ParseCommandHeaders(cmd, args)
|
crt.ParseCommandHeaders(cmd, args)
|
||||||
return existingPreRunE(cmd, args)
|
return existingPreRunE(cmd, args)
|
||||||
}
|
}
|
||||||
|
wrapConfigFn := kubeConfigFlags.WrapConfigFn
|
||||||
// Wraps CommandHeaderRoundTripper around standard RoundTripper.
|
// Wraps CommandHeaderRoundTripper around standard RoundTripper.
|
||||||
kubeConfigFlags.WrapConfigFn = func(c *rest.Config) *rest.Config {
|
kubeConfigFlags.WrapConfigFn = func(c *rest.Config) *rest.Config {
|
||||||
|
if wrapConfigFn != nil {
|
||||||
|
c = wrapConfigFn(c)
|
||||||
|
}
|
||||||
c.Wrap(func(rt http.RoundTripper) http.RoundTripper {
|
c.Wrap(func(rt http.RoundTripper) http.RoundTripper {
|
||||||
// Must be separate RoundTripper; not "crt" closure.
|
// Must be separate RoundTripper; not "crt" closure.
|
||||||
// Fixes: https://github.com/kubernetes/kubectl/issues/1098
|
// Fixes: https://github.com/kubernetes/kubectl/issues/1098
|
||||||
|
Loading…
Reference in New Issue
Block a user