Fix no error with duplicate connector name
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -34,10 +34,14 @@ func NewConnectorRegistry() *ConnectorRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
func (cr *ConnectorRegistry) Register(connectorID string, connector Connector) {
|
||||
func (cr *ConnectorRegistry) Register(connectorID string, connector Connector) error {
|
||||
cr.Lock()
|
||||
defer cr.Unlock()
|
||||
if _, ok := cr.connectors[connectorID]; ok {
|
||||
return fmt.Errorf("connector %q already registered", connectorID)
|
||||
}
|
||||
cr.connectors[connectorID] = connector
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *ConnectorRegistry) Get(connectorID string) (Connector, error) {
|
||||
|
||||
@@ -178,7 +178,9 @@ func (impl *Implm) Run(
|
||||
|
||||
defaultConnectorRegistry := connector.NewConnectorRegistry()
|
||||
for _, connector := range impl.cfg.Connectors {
|
||||
defaultConnectorRegistry.Register(connector.Name, connector.Config)
|
||||
if err := defaultConnectorRegistry.Register(connector.Name, connector.Config); err != nil {
|
||||
return fmt.Errorf("cannot register connector: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
usrmgrService, err := usrmgr.NewService(
|
||||
|
||||
Reference in New Issue
Block a user