make kubectl factory flag binding optional

This commit is contained in:
deads2k
2015-01-20 17:07:36 -05:00
parent 6ff26d924c
commit 500bb3a7fa
4 changed files with 52 additions and 4 deletions

View File

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