mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
make kubectl factory flag binding optional
This commit is contained in:
@@ -69,11 +69,18 @@ type Factory struct {
|
||||
}
|
||||
|
||||
// NewFactory creates a factory with the default Kubernetes resources defined
|
||||
func NewFactory() *Factory {
|
||||
// if optionalClientConfig is nil, then flags will be bound to a new clientcmd.ClientConfig.
|
||||
// if optionalClientConfig is not nil, then this factory will make use of it.
|
||||
func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
||||
mapper := kubectl.ShortcutExpander{latest.RESTMapper}
|
||||
|
||||
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
|
||||
clientConfig := DefaultClientConfig(flags)
|
||||
|
||||
clientConfig := optionalClientConfig
|
||||
if optionalClientConfig == nil {
|
||||
clientConfig = DefaultClientConfig(flags)
|
||||
}
|
||||
|
||||
clients := &clientCache{
|
||||
clients: make(map[string]*client.Client),
|
||||
loader: clientConfig,
|
||||
|
||||
Reference in New Issue
Block a user