Commit d465611
committed
feat(mysql): move DSN to env var override with percent-encoding (Bug 1)
Phase 3 fix from issue torrust#410.
- Add percent-encoding = "2.0" to Cargo.toml
- TrackerServiceConfig: add optional database_path field (Some for MySQL, None
for SQLite) with serde skip_serializing_if so it only appears in template
context for MySQL
- EnvContext::new_with_mysql: percent-encode username and password using a custom
USERINFO_ENCODE AsciiSet (encodes @, :, /, #, ?, %, + but NOT unreserved chars
like _ so tracker_user stays tracker_user, not tracker%5Fuser)
- Build full MySQL DSN and store in tracker.database_path
- EnvContext::new_with_mysql: add mysql_host (String) and mysql_port (u16) params
so the DSN can be constructed without needing domain types at the infra layer
- templates/docker-compose/.env.tera: add
TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__PATH inside the Tracker Service
Configuration section (inside {%- if mysql %} block); move before MySQL section
- templates/docker-compose/docker-compose.yml.tera: inject the new env var into
the tracker service environment section, conditionally on {%- if mysql %}
- templates/tracker/tracker.toml.tera: remove mysql path = line; replace with a
comment explaining the env var override (no Tera tag needed — comment is static)
- TrackerContext: remove MysqlTemplateConfig struct and mysql field entirely; the
MySQL case only needs database_driver = mysql now
- Add tests: percent-encoded DSN, alphanumeric DSN, database_path None for SQLite
- Update project_generator.rs test: hardcoded template updated and assertions
changed to confirm driver = mysql and absence of path/password lines
- Update issue doc: mark all Phase 1-4 items [x]; add Phase 5 status note
- 2314 tests pass1 parent 81ed6d1 commit d465611
9 files changed
Lines changed: 173 additions & 108 deletions
File tree
- docs/issues
- src
- application/services/rendering
- infrastructure/templating
- docker_compose/template/wrappers/env
- tracker/template
- renderer
- wrapper/tracker_config
- templates
- docker-compose
- tracker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
Lines changed: 37 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
294 | 294 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
306 | | - | |
| 305 | + | |
| 306 | + | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
319 | 321 | | |
320 | 322 | | |
321 | 323 | | |
| |||
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | | - | |
| 333 | + | |
332 | 334 | | |
333 | | - | |
334 | | - | |
| 335 | + | |
| 336 | + | |
335 | 337 | | |
336 | 338 | | |
337 | 339 | | |
| |||
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
352 | | - | |
| 354 | + | |
353 | 355 | | |
354 | | - | |
| 356 | + | |
355 | 357 | | |
356 | 358 | | |
357 | | - | |
| 359 | + | |
358 | 360 | | |
359 | | - | |
| 361 | + | |
360 | 362 | | |
361 | 363 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
366 | 368 | | |
367 | 369 | | |
368 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| 218 | + | |
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
| |||
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| 233 | + | |
| 234 | + | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
| |||
Lines changed: 106 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
14 | 38 | | |
15 | 39 | | |
16 | 40 | | |
| |||
21 | 45 | | |
22 | 46 | | |
23 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
24 | 55 | | |
25 | 56 | | |
26 | 57 | | |
| |||
105 | 136 | | |
106 | 137 | | |
107 | 138 | | |
| 139 | + | |
108 | 140 | | |
109 | 141 | | |
110 | 142 | | |
| |||
119 | 151 | | |
120 | 152 | | |
121 | 153 | | |
122 | | - | |
123 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
124 | 158 | | |
125 | 159 | | |
126 | 160 | | |
| |||
137 | 171 | | |
138 | 172 | | |
139 | 173 | | |
| 174 | + | |
| 175 | + | |
140 | 176 | | |
141 | 177 | | |
142 | 178 | | |
| |||
149 | 185 | | |
150 | 186 | | |
151 | 187 | | |
| 188 | + | |
| 189 | + | |
152 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
153 | 196 | | |
154 | 197 | | |
155 | 198 | | |
156 | 199 | | |
157 | 200 | | |
| 201 | + | |
158 | 202 | | |
159 | 203 | | |
160 | 204 | | |
| |||
277 | 321 | | |
278 | 322 | | |
279 | 323 | | |
| 324 | + | |
| 325 | + | |
280 | 326 | | |
281 | 327 | | |
282 | 328 | | |
| |||
312 | 358 | | |
313 | 359 | | |
314 | 360 | | |
| 361 | + | |
| 362 | + | |
315 | 363 | | |
316 | 364 | | |
317 | 365 | | |
| |||
339 | 387 | | |
340 | 388 | | |
341 | 389 | | |
| 390 | + | |
| 391 | + | |
342 | 392 | | |
343 | 393 | | |
344 | 394 | | |
| |||
349 | 399 | | |
350 | 400 | | |
351 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
352 | 456 | | |
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
320 | | - | |
321 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
322 | 323 | | |
323 | 324 | | |
324 | 325 | | |
| |||
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
404 | | - | |
| 405 | + | |
405 | 406 | | |
406 | 407 | | |
407 | 408 | | |
| |||
0 commit comments