diff --git a/pkg/admission/plugins.go b/pkg/admission/plugins.go index 09fc449e1db..02193e474c2 100644 --- a/pkg/admission/plugins.go +++ b/pkg/admission/plugins.go @@ -63,18 +63,19 @@ func RegisterPlugin(name string, plugin Factory) { plugins[name] = plugin } -// GetPlugin creates an instance of the named plugin, or nil if the name is not -// known. The error is returned only when the named provider was known but failed -// to initialize. The config parameter specifies the io.Reader handler of the -// configuration file for the cloud provider, or nil for no configuration. -func GetPlugin(name string, client clientset.Interface, config io.Reader) (Interface, error) { +// getPlugin creates an instance of the named plugin. It returns `false` if the +// the name is not known. The error is returned only when the named provider was +// known but failed to initialize. The config parameter specifies the io.Reader +// handler of the configuration file for the cloud provider, or nil for no configuration. +func getPlugin(name string, client clientset.Interface, config io.Reader) (Interface, bool, error) { pluginsMutex.Lock() defer pluginsMutex.Unlock() f, found := plugins[name] if !found { - return nil, nil + return nil, false, nil } - return f(client, config) + ret, err := f(client, config) + return ret, true, err } // InitPlugin creates an instance of the named interface. @@ -99,11 +100,11 @@ func InitPlugin(name string, client clientset.Interface, configFilePath string) defer config.Close() } - plugin, err := GetPlugin(name, client, config) + plugin, found, err := getPlugin(name, client, config) if err != nil { glog.Fatalf("Couldn't init admission plugin %q: %v", name, err) } - if plugin == nil { + if !found { glog.Fatalf("Unknown admission plugin: %s", name) }