kubeadm: refactor config

1) break object into substructures
2) seperate a config object for master and node
This commit is contained in:
Mike Danese
2016-09-28 23:36:18 -07:00
parent 3933ddbc9a
commit 56ea178e7c
20 changed files with 317 additions and 269 deletions

View File

@@ -32,8 +32,10 @@ import (
type Factory func(config io.Reader) (Interface, error)
// All registered cloud providers.
var providersMutex sync.Mutex
var providers = make(map[string]Factory)
var (
providersMutex sync.Mutex
providers = make(map[string]Factory)
)
// RegisterCloudProvider registers a cloudprovider.Factory by name. This
// is expected to happen during app startup.
@@ -47,6 +49,27 @@ func RegisterCloudProvider(name string, cloud Factory) {
providers[name] = cloud
}
// IsCloudProvider returns true if name corresponds to an already registered
// cloud provider.
func IsCloudProvider(name string) bool {
providersMutex.Lock()
defer providersMutex.Unlock()
_, found := providers[name]
return found
}
// CloudProviders returns the name of all registered cloud providers in a
// string slice
func CloudProviders() []string {
names := []string{}
providersMutex.Lock()
defer providersMutex.Unlock()
for name := range providers {
names = append(names, name)
}
return names
}
// GetCloudProvider creates an instance of the named cloud provider, or nil if
// the name is not known. The error return is only used if the named provider
// was known but failed to initialize. The config parameter specifies the