Commit c671139
authored
Send MS Teams V2 notifications (#248)
* refactor: replace interface{} with any and simplify code
- Use `any` alias instead of `interface{}` in event handlers
- Remove redundant `== true` in boolean checks
- Simplify `ObjectMeta.Annotations` to `Annotations`
* chore: add asdf tool-versions to gitignore
* refactor: remove unused kubeclientset field from Controller
- Remove kubeclientset from Controller struct
- Fix error handling in job event handlers
* feat: add MS Teams v2 notification support
- Add HTTP client with retry logic
- Implement MS Teams adaptive card structure
- Register msteamsv2 in notification registry
- Update README with Teams config examples
- Refactor slack env check logic
* chore: update module path and add MSTeamsV2 implementation
- Change module path from yutachaos to remmercier
- Add kube-job-notifier binary to gitignore
- Implement MSTeamsV2 NotifyStart method
- Add environment variable checks for notification enablement
- Remove unused httpclient dependency in msteamsv2.go
* chore: add .vscode to gitignore and reorder imports
- Ignore .vscode directory
- Group standard library imports before external packages
* feat: implement MS Teams v2 notifications
- Add message template with job details formatting
- Implement NotifyStart, NotifySuccess, and NotifyFailed methods
- Format text with double line breaks for Adaptive Cards
- Update card version to 1.4
* feat: add cronjob filtering by regex pattern
- Add CRONJOB_REGEX env var to filter monitored cronjobs
- Check regex match early in event handlers
- Move cronjob name lookup before pod wait
- Update README with new config option
* refactor: remove unused httpclient package
- Delete pkg/httpclient/http.go with HTTPClient implementation
* test: add comprehensive tests for MS Teams V2 notifications
- Cover webhook initialization and validation
- Test adaptive card payload generation
- Verify notification methods (start, success, failed)
- Add error handling test cases
* refactor: improve error handling in job event handlers
- Handle getPodFromControllerUID errors properly
- Fix indentation in notification block
- Remove unused isCronjobNameIncluded function1 parent ab53099 commit c671139
File tree
9 files changed
+513
-46
lines changed- pkg/notification
9 files changed
+513
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | | - | |
51 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | | - | |
14 | | - | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
79 | 85 | | |
80 | 86 | | |
81 | | - | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
85 | 100 | | |
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
89 | | - | |
| 104 | + | |
90 | 105 | | |
91 | 106 | | |
92 | 107 | | |
93 | 108 | | |
94 | 109 | | |
95 | 110 | | |
96 | | - | |
97 | | - | |
98 | 111 | | |
99 | | - | |
| 112 | + | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
103 | | - | |
104 | | - | |
| 116 | + | |
105 | 117 | | |
106 | | - | |
| 118 | + | |
| 119 | + | |
107 | 120 | | |
| 121 | + | |
108 | 122 | | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
113 | 127 | | |
114 | | - | |
| 128 | + | |
115 | 129 | | |
116 | 130 | | |
117 | 131 | | |
| |||
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | | - | |
| 138 | + | |
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
129 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
130 | 153 | | |
131 | 154 | | |
132 | 155 | | |
133 | 156 | | |
134 | | - | |
| 157 | + | |
135 | 158 | | |
136 | 159 | | |
137 | 160 | | |
138 | 161 | | |
139 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
140 | 166 | | |
| 167 | + | |
141 | 168 | | |
142 | 169 | | |
143 | 170 | | |
| |||
151 | 178 | | |
152 | 179 | | |
153 | 180 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
185 | 206 | | |
186 | 207 | | |
187 | 208 | | |
188 | | - | |
| 209 | + | |
189 | 210 | | |
190 | 211 | | |
191 | 212 | | |
| |||
207 | 228 | | |
208 | 229 | | |
209 | 230 | | |
210 | | - | |
| 231 | + | |
211 | 232 | | |
212 | 233 | | |
213 | 234 | | |
| |||
232 | 253 | | |
233 | 254 | | |
234 | 255 | | |
235 | | - | |
| 256 | + | |
236 | 257 | | |
237 | 258 | | |
238 | 259 | | |
| |||
241 | 262 | | |
242 | 263 | | |
243 | 264 | | |
244 | | - | |
| 265 | + | |
245 | 266 | | |
246 | 267 | | |
247 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments