Skip to content

Commit

Permalink
remove factory function
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-tceretian committed Feb 14, 2023
1 parent be496f5 commit e03b095
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions notify/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ type NotificationChannel interface {
notify.ResolvedSender
}

func Factory(receiverType string) (func(receivers.FactoryConfig) (NotificationChannel, error), bool) {
receiverType = strings.ToLower(receiverType)
factory, exists := receiverFactories[receiverType]
return factory, exists
}

// wrap wraps the notifier's factory errors with receivers.ReceiverInitError
func wrap[T NotificationChannel](f func(fc receivers.FactoryConfig) (T, error)) func(receivers.FactoryConfig) (NotificationChannel, error) {
return func(fc receivers.FactoryConfig) (NotificationChannel, error) {
Expand Down Expand Up @@ -170,14 +164,16 @@ func (ib IntegrationsBuilder) buildReceiverIntegration(r *GrafanaReceiver, tmpl
Err: err,
}
}
receiverFactory, exists := Factory(r.Type)

receiverType := strings.ToLower(r.Type)
factory, exists := receiverFactories[receiverType]
if !exists {
return nil, InvalidReceiverError{
Receiver: r,
Err: fmt.Errorf("notifier %s is not supported", r.Type),
}
}
n, err := receiverFactory(factoryConfig)
n, err := factory(factoryConfig)
if err != nil {
return nil, InvalidReceiverError{
Receiver: r,
Expand Down

0 comments on commit e03b095

Please sign in to comment.