Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let admission plugins indicate they want nothing #24421

Merged
merged 1 commit into from
Apr 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions pkg/admission/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}

Expand Down