Skip to content

Commit

Permalink
Add check for multiple descriptors matching the same key.
Browse files Browse the repository at this point in the history
Signed-off-by: Milan Lenco <[email protected]>
  • Loading branch information
Milan Lenco committed May 17, 2019
1 parent 9875d2b commit 36a4186
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/kvscheduler/internal/registry/registry_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

. "github.com/ligato/vpp-agent/plugins/kvscheduler/api"
"github.com/ligato/vpp-agent/plugins/kvscheduler/internal/utils"
"fmt"
)

const (
Expand Down Expand Up @@ -111,8 +112,11 @@ func (reg *registry) GetDescriptorForKey(key string) *KVDescriptor {
var keyDescriptor *KVDescriptor
for _, descriptor := range reg.descriptors {
if descriptor.KeySelector(key) {
if keyDescriptor != nil {
panic(fmt.Sprintf("key %s is selected by both %s and %s descriptors",
key, keyDescriptor.Name, descriptor.Name))
}
keyDescriptor = descriptor
break
}
}
// add entry to cache
Expand Down

0 comments on commit 36a4186

Please sign in to comment.