fix incorrect logic

pull/6/head
guangxuli 2017-08-17 22:59:45 +08:00
parent 1d633b7fdd
commit d4b41afe59
1 changed files with 7 additions and 5 deletions

View File

@ -67,13 +67,15 @@ func (ps *Plugins) Registered() []string {
func (ps *Plugins) Register(name string, plugin Factory) {
ps.lock.Lock()
defer ps.lock.Unlock()
_, found := ps.registry[name]
if found {
glog.Fatalf("Admission plugin %q was registered twice", name)
}
if ps.registry == nil {
if ps.registry != nil {
_, found := ps.registry[name]
if found {
glog.Fatalf("Admission plugin %q was registered twice", name)
}
} else {
ps.registry = map[string]Factory{}
}
glog.V(1).Infof("Registered admission plugin %q", name)
ps.registry[name] = plugin
}