Commit 91c48cc
authored
## Summary
Brings the \`[global]\` and \`[docker]\` unknown-key warnings into
parity with job sections so operator typos now suggest the nearest
mapstructure key. Pre-fix:
\`\`\`
WARN Unknown configuration key 'webhook-defauls-preset' in [global]
section (typo?)
\`\`\`
Post-fix:
\`\`\`
WARN Unknown configuration key 'webhook-defauls-preset' in [global]
section (did you mean 'webhook-default-preset'?)
\`\`\`
Closes [#678](#678).
## Approach
Extracted a \`logSectionUnknownKeyWarnings(logger, section, unknownKeys,
knownKeys, filename)\` helper that mirrors the filename / suggestion
matrix already used by \`logJobUnknownKeyWarnings\`, then routed both
\`[global]\` and \`[docker]\` paths through it from both call sites
(file-based \`logUnknownKeyWarnings\` and string-based
\`BuildFromString\`).
Known keys come from \`extractMapstructureKeys(Config{}.Global)\` and
\`extractMapstructureKeys(DockerConfig{})\` via thin \`globalKnownKeys\`
/ \`dockerKnownKeys\` helpers, so the suggestion list cannot drift from
the actual decoded struct — the same drift-resistance pattern as
\`getKnownKeysForJobType\`.
## Tests
Three new tests in \`cli/config_decode_test.go\`:
1. **\`TestGlobalSectionUnknownKeyWarning_DidYouMean\`** — the exact
mistype called out in the issue body (\`webhook-defauls-preset\` →
\`webhook-default-preset\`).
2. **\`TestGlobalSectionUnknownKeyWarning_NoSuggestion\`** — locks the
fallback to \`(typo?)\` when no close match exists (asymmetry against
the suggestion case is what makes the parity fix meaningful).
3. **\`TestDockerSectionUnknownKeyWarning_DidYouMean\`** — same parity
assertion for the \`[docker]\` path so a future code split can't
silently drop suggestions on one half.
## Test plan
- [x] \`go test ./...\` passes (full repo, 14 packages, ~58s)
- [x] \`golangci-lint run\` clean (intentional typos in test carry
\`//nolint:misspell\`)
- [x] \`go vet ./...\` clean
- [ ] CI green
## References
- Surfaced in: [#677](#677)
(parallel-reviewer pass)
- Tracks against:
[#621](#621) (global-keys
drift detection family)
2 files changed
Lines changed: 203 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 244 | + | |
| 245 | + | |
247 | 246 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 247 | + | |
| 248 | + | |
251 | 249 | | |
252 | 250 | | |
253 | 251 | | |
254 | 252 | | |
255 | 253 | | |
256 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
257 | 299 | | |
258 | 300 | | |
259 | 301 | | |
| |||
322 | 364 | | |
323 | 365 | | |
324 | 366 | | |
325 | | - | |
326 | | - | |
327 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
328 | 370 | | |
329 | | - | |
330 | | - | |
| 371 | + | |
| 372 | + | |
331 | 373 | | |
332 | 374 | | |
333 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
470 | 472 | | |
471 | 473 | | |
472 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
473 | 623 | | |
474 | 624 | | |
475 | 625 | | |
| |||
0 commit comments