Commit c795127
committed
ci(lint): adopt strict golangci-lint config + cross-platform CI gate
Closes #153.
Adopts the `default: all` golangci-lint v2 config proposed in #153 and
reconciles the project against it: zero lint findings on both linux/amd64
(host) and windows/amd64, with a CI lint matrix gate so the strict
config doesn't erode silently.
## Strict-lint adoption
- `.golangci.yml`: `default: all` with the relaxations from the issue
(depguard, exhaustruct, gochecknoinits, wsl, lll, errchkjson, ireturn,
gocheckcompilerdirectives) plus three documented additions: noinlineerr
(200+ inline if-err sites; conversion would create variable-scope
leaks), goconst on _test.go (test fixtures live inside backtick strings;
substitution desyncs expected vs got), gomodguard (deprecated in v2.12+,
neither allow nor blocklist configured).
- `gomoddirectives.replace-allow-list` for github.com/siderolabs/talos and
.../pkg/machinery — required while upstream declines siderolabs/talos#12652.
## CI lint gate
- New `lint:` job in .github/workflows/pr.yml runs golangci-lint v2.12.2
on Ubuntu AND Windows runners (matching the existing `test:` matrix).
Build-tagged Windows files (secureperm_windows.go, template_windows_test.go)
are now actually evaluated on every PR instead of silently diverging.
- `.gitattributes` pins LF for *.go so Windows runners don't surface
spurious gofmt errors from autocrlf-converted CRLF endings.
## Bug fixes surfaced by the lint pass
- pkg/commands/preflight.go: `nilerr` — two error sites swallowed errors
with `return nil` after `if err != nil`. Now propagate.
- pkg/commands/rotate_ca_handler.go: `nosprintfhostport` — URL constructed
via fmt.Sprintf("%s:%s", host, port) broke for IPv6 endpoints. Switched
to net.JoinHostPort.
- pkg/age/age.go + pkg/engine/engine.go: `forcetypeassert` — type assertions
without ok-form panicked on unexpected YAML shapes. Switched to ok-form
with wrapped error returns.
- pkg/yamltools/yamltools.go + pkg/engine/engine.go: `exhaustive` — yaml.Kind
switches missed DocumentNode/AliasNode/ScalarNode/SequenceNode. Added
explicit cases with documented intent.
- pkg/commands/init.go: `writeGitignoreFile` reported "Updated" for files
it just created (existence check ran AFTER WriteFile). Capture stat
before write; pinned by TestContract_WriteGitignoreFile_CreatedVsUpdatedReporting.
- pkg/age/age.go: `refuseIfLeftoverBackups` (RotateKeys Phase 0) failed
open on permission/sharing/transient I/O errors — only os.IsNotExist
is the "no leftover" answer; everything else now fails closed.
- pkg/engine/helm/files.go: `Lines()` panicked on empty file content
(s[len(s)-1] without length guard). Added early-return guard. Bug
is verbatim from upstream Helm v3.20.2; we ship the code so we own
the fix.
- pkg/commands/template.go: modeline-omitted endpoints overwrote the
PreRunE-seeded defaultLocalEndpoint; modeline path generation
(root-level basename fallback) was asymmetric with resolution.
Both fixed.
- pkg/commands/root.go: dropped duplicate stderr print of modeline
parse failures — cobra surfaces the wrapped error at the command
boundary already.
## Refactors
- pkg/age/age.go: EncryptSecretsFile / DecryptSecretsFile / RotateKeys
decomposed into named helpers (encryptYAMLPair, decryptYAMLPair,
loadOrGenerateIdentity, incrementalEncryptMap, plus rotation-phase
helpers). All 19 contract tests still pass.
- pkg/commands/apply.go + template.go: split monolithic per-file closures
into named helpers (applyOneFileTemplateMode, applyOneFileDirectPatchMode,
templateOneFile, buildTemplateRunner, etc.).
- pkg/engine/engine.go: extractResourceData rewritten — was an unguarded
yamlValue.(string) assertion that would panic; now returns a typed error.
## Error-handling migration
~220 sites migrated from fmt.Errorf("...: %w", err) to cockroachdb/errors.Wrap
/ Wrapf (project standard). Adds operator-facing hints via errors.WithHint
at boundaries.
## Const hoisting
~150 repeated literals (k8s/COSI keys, Helm template names, file modes,
preset/chart names, test fixtures) moved to package-level constants with
documented intent — single source of truth, single rename per future change.
## Verification
- go build ./... — clean (host + GOOS=windows)
- go test ./... -count=1 — green (8/8 packages)
- go test ./... -race — green
- golangci-lint run — 0 issues (host + GOOS=windows)
- Manual smoke: talm init --preset cozystack --name test-cluster creates
expected files; ancestor-project refusal works; --root . opt-in works.
Bulk of the diff is mechanical: const extraction, error-wrap migration,
blank-line discipline, and //nolint: annotations with rationale where
the rule cannot be satisfied without losing fidelity (project's
"200% rule" on disabling lints).
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>1 parent b57638a commit c795127
62 files changed
Lines changed: 4109 additions & 2028 deletions
File tree
- .github/workflows
- charts
- pkg
- age
- commands
- engine
- helm
- modeline
- secureperm
- yamltools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
25 | 49 | | |
26 | 50 | | |
27 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 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 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | | - | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | | - | |
| 24 | + | |
23 | 25 | | |
24 | | - | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | | - | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
32 | | - | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | | - | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | | - | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
55 | 56 | | |
56 | | - | |
| 57 | + | |
57 | 58 | | |
58 | | - | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | | - | |
| 73 | + | |
71 | 74 | | |
72 | | - | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
77 | | - | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
83 | | - | |
84 | | - | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | | - | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | | - | |
| 96 | + | |
94 | 97 | | |
95 | | - | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
| |||
227 | 226 | | |
228 | 227 | | |
229 | 228 | | |
| 229 | + | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| |||
0 commit comments