@@ -28,11 +28,6 @@ import (
28
28
"github.com/grafana/alerting/receivers/wecom"
29
29
)
30
30
31
- type NotificationChannel interface {
32
- notify.Notifier
33
- notify.ResolvedSender
34
- }
35
-
36
31
// BuildReceiverIntegrations builds notifiers of the receiver and wraps each of them in Integration.
37
32
func BuildReceiverIntegrations (
38
33
receiver GrafanaReceiverConfig ,
@@ -46,105 +41,110 @@ func BuildReceiverIntegrations(
46
41
) []* Integration {
47
42
var integrations []* Integration
48
43
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 ) {
50
50
logger := newLogger ("ngalert.notifier." + cfg .Type , "notifierUID" , cfg .UID )
51
51
n := f (logger )
52
52
i := NewIntegration (n , n , cfg .Type , idx )
53
53
integrations = append (integrations , i )
54
54
}
55
55
56
56
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 {
58
58
return alertmanager .New (cfg .Settings , cfg .Metadata , img , l )
59
59
})
60
60
}
61
61
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 {
63
63
return dinding .New (cfg .Settings , cfg .Metadata , tmpl , ns , l )
64
64
})
65
65
}
66
66
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 {
68
68
return discord .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l , version )
69
69
})
70
70
}
71
71
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 {
73
73
return email .New (cfg .Settings , cfg .Metadata , tmpl , es , img , l )
74
74
})
75
75
}
76
76
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 {
78
78
return googlechat .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l , version )
79
79
})
80
80
}
81
81
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 {
83
83
return kafka .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
84
84
})
85
85
}
86
86
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 {
88
88
return line .New (cfg .Settings , cfg .Metadata , tmpl , ns , l )
89
89
})
90
90
}
91
91
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 {
93
93
return opsgenie .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
94
94
})
95
95
}
96
96
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 {
98
98
return pagerduty .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
99
99
})
100
100
}
101
101
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 {
103
103
return pushover .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
104
104
})
105
105
}
106
106
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 {
108
108
return sensugo .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
109
109
})
110
110
}
111
111
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 {
113
113
return slack .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l , version )
114
114
})
115
115
}
116
116
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 {
118
118
return teams .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
119
119
})
120
120
}
121
121
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 {
123
123
return telegram .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
124
124
})
125
125
}
126
126
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 {
128
128
return threema .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l )
129
129
})
130
130
}
131
131
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 {
133
133
return victorops .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l , version )
134
134
})
135
135
}
136
136
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 {
138
138
return webhook .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l , orgID )
139
139
})
140
140
}
141
141
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 {
143
143
return wecom .New (cfg .Settings , cfg .Metadata , tmpl , ns , l )
144
144
})
145
145
}
146
146
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 {
148
148
return webex .New (cfg .Settings , cfg .Metadata , tmpl , ns , img , l , orgID )
149
149
})
150
150
}
0 commit comments