Skip to content

Commit 224a05f

Browse files
hide interface
1 parent eb3e987 commit 224a05f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

notify/factory.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ import (
2828
"github.com/grafana/alerting/receivers/wecom"
2929
)
3030

31-
type NotificationChannel interface {
32-
notify.Notifier
33-
notify.ResolvedSender
34-
}
35-
3631
// BuildReceiverIntegrations builds notifiers of the receiver and wraps each of them in Integration.
3732
func BuildReceiverIntegrations(
3833
receiver GrafanaReceiverConfig,
@@ -46,105 +41,110 @@ func BuildReceiverIntegrations(
4641
) []*Integration {
4742
var integrations []*Integration
4843

49-
createIntegration := func(idx int, cfg receivers.Metadata, f func(logger logging.Logger) NotificationChannel) {
44+
type notificationChannel interface {
45+
notify.Notifier
46+
notify.ResolvedSender
47+
}
48+
49+
createIntegration := func(idx int, cfg receivers.Metadata, f func(logger logging.Logger) notificationChannel) {
5050
logger := newLogger("ngalert.notifier."+cfg.Type, "notifierUID", cfg.UID)
5151
n := f(logger)
5252
i := NewIntegration(n, n, cfg.Type, idx)
5353
integrations = append(integrations, i)
5454
}
5555

5656
for i, cfg := range receiver.AlertmanagerConfigs {
57-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
57+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
5858
return alertmanager.New(cfg.Settings, cfg.Metadata, img, l)
5959
})
6060
}
6161
for i, cfg := range receiver.DingdingConfigs {
62-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
62+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
6363
return dinding.New(cfg.Settings, cfg.Metadata, tmpl, ns, l)
6464
})
6565
}
6666
for i, cfg := range receiver.DiscordConfigs {
67-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
67+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
6868
return discord.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l, version)
6969
})
7070
}
7171
for i, cfg := range receiver.EmailConfigs {
72-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
72+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
7373
return email.New(cfg.Settings, cfg.Metadata, tmpl, es, img, l)
7474
})
7575
}
7676
for i, cfg := range receiver.GooglechatConfigs {
77-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
77+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
7878
return googlechat.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l, version)
7979
})
8080
}
8181
for i, cfg := range receiver.KafkaConfigs {
82-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
82+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
8383
return kafka.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
8484
})
8585
}
8686
for i, cfg := range receiver.LineConfigs {
87-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
87+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
8888
return line.New(cfg.Settings, cfg.Metadata, tmpl, ns, l)
8989
})
9090
}
9191
for i, cfg := range receiver.OpsgenieConfigs {
92-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
92+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
9393
return opsgenie.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
9494
})
9595
}
9696
for i, cfg := range receiver.PagerdutyConfigs {
97-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
97+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
9898
return pagerduty.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
9999
})
100100
}
101101
for i, cfg := range receiver.PushoverConfigs {
102-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
102+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
103103
return pushover.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
104104
})
105105
}
106106
for i, cfg := range receiver.SensugoConfigs {
107-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
107+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
108108
return sensugo.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
109109
})
110110
}
111111
for i, cfg := range receiver.SlackConfigs {
112-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
112+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
113113
return slack.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l, version)
114114
})
115115
}
116116
for i, cfg := range receiver.TeamsConfigs {
117-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
117+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
118118
return teams.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
119119
})
120120
}
121121
for i, cfg := range receiver.TelegramConfigs {
122-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
122+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
123123
return telegram.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
124124
})
125125
}
126126
for i, cfg := range receiver.ThreemaConfigs {
127-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
127+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
128128
return threema.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l)
129129
})
130130
}
131131
for i, cfg := range receiver.VictoropsConfigs {
132-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
132+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
133133
return victorops.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l, version)
134134
})
135135
}
136136
for i, cfg := range receiver.WebhookConfigs {
137-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
137+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
138138
return webhook.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l, orgID)
139139
})
140140
}
141141
for i, cfg := range receiver.WecomConfigs {
142-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
142+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
143143
return wecom.New(cfg.Settings, cfg.Metadata, tmpl, ns, l)
144144
})
145145
}
146146
for i, cfg := range receiver.WebexConfigs {
147-
createIntegration(i, cfg.Metadata, func(l logging.Logger) NotificationChannel {
147+
createIntegration(i, cfg.Metadata, func(l logging.Logger) notificationChannel {
148148
return webex.New(cfg.Settings, cfg.Metadata, tmpl, ns, img, l, orgID)
149149
})
150150
}

0 commit comments

Comments
 (0)