mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #24421 from deads2k/fix-admission
Automatic merge from submit-queue let admission plugins indicate they want nothing An admission plugin can return `nil, nil` for construction. This is useful for dealing with cases where the `config` passed to you effectively means, "no work". The calling code already handles this. @derekwaynecarr
This commit is contained in:
commit
f583174d76
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user