Commit 00358fd
authored
feat(config): migrate to Talos v1.12 multi-document config format (#116)
* feat(config): migrate to Talos v1.12 multi-document config format
Add support for the Talos v1.12 multi-document configuration format. When
TalosVersion is set to v1.12 or later (via Chart.yaml or --talos-version CLI
flag), templates generate separate YAML documents instead of the deprecated
monolithic machine.network and machine.registries fields.
Closes #100
Engine:
- Pass TalosVersion through the Helm values map into the template rendering
context (available as .TalosVersion), avoiding global mutable state
- Remove unused ctx and chrt parameters from applyPatchesAndRenderConfig
Chart templates (cozystack + generic):
- Split talos.config into shared sub-templates to eliminate duplication:
talos.config.machine.common, talos.config.cluster,
talos.config.network.legacy, talos.config.network.multidoc
- Version dispatcher selects legacy or multi-doc format based on semverCompare
- New v1.12 document types generated: HostnameConfig, ResolverConfig,
LinkConfig, BondConfig, VLANConfig, RegistryMirrorConfig, Layer2VIPConfig
Bug fix:
- Fix nr_hugepages rendering inside with block (was producing empty string
for non-zero values due to .Values being inaccessible when dot is rebound)
Backward compatibility:
- Legacy format is fully preserved when TalosVersion is empty or < v1.12
- All legacy regression tests pass unchanged
Tests:
- isTalosConfigPatch and extractExtraDocuments tests for all 7 new document
types
- Offline rendering tests for both charts x both roles x both formats
- Version edge cases: pre-release, two-component version strings
- Concurrent render test with race detector
- nr_hugepages rendering test for both legacy and multi-doc paths
- Regression test from #119 for offline lookup producing empty interface
Code style:
- Replace interface{} with any across engine package
- Use maps.Copy instead of range+assign loops
- Use range over int for simple counting loops
- Use strings.Repeat instead of += concatenation
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
* fix(engine): validate TalosVersion before template rendering
Call ParseContractFromVersion early in Render() so malformed values
(e.g. "latest", "foobar") surface a user-friendly "invalid
talos-version" error instead of the opaque "semverCompare: invalid
semantic version" that otherwise escapes from deep inside the Helm
engine template evaluation.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
* test(engine): cover bond/vlan topologies, invalid version, Layer2VIPConfig
- TestRenderInvalidTalosVersion: exercises the new early validation.
- TestMultiDocCozystack_BondTopology / TestMultiDocGeneric_BondTopology:
assert BondConfig emission with mock links/routes/addresses lookups.
- TestMultiDocCozystack_VlanOnBondTopology /
TestMultiDocGeneric_VlanOnBondTopology: assert BondConfig + VLANConfig
combined emission when the default route goes through a VLAN.
- TestMultiDocCozystack_ControlPlane: add positive assert for
Layer2VIPConfig since cozystack defaults set floatingIP.
- TestLegacy/MultiDocCozystack_NrHugepages: restore the package-level
helmEngine.LookupFunc via t.Cleanup for test isolation.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
* docs: refine multi-doc README note and machine.common helper comment
- README: clarify that not all multi-doc types are always present —
HostnameConfig/ResolverConfig and one network interface document are
always emitted, Layer2VIPConfig depends on floatingIP on controlplane,
and RegistryMirrorConfig is cozystack-only.
- charts/cozystack _helpers.tpl: the talos.config.machine.common helper
also renders nodeLabels for controlplane nodes — update the comment.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
* fix(helpers): attach Layer2VIP to VLAN interface in multi-doc path
In the VLAN branch of talos.config.network.multidoc, $interfaceName is
rewritten to the parent link, while addresses/routes are emitted on the
VLAN link ($defaultLinkName). Using $interfaceName for Layer2VIPConfig.link
moved the VIP off the configured VLAN. Select $defaultLinkName when the
default link is a VLAN so the VIP stays attached to the VLAN interface,
matching the legacy path behavior.
Address review feedback from coderabbitai on charts/cozystack/templates/_helpers.tpl:229.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
* fix(helpers): attach Layer2VIP to VLAN interface in generic multi-doc path
Mirror of the cozystack fix: when the default link is a VLAN,
$interfaceName is rewritten to the parent link while the VLAN
addresses/routes are emitted on $defaultLinkName. Use $defaultLinkName
for Layer2VIPConfig.link in that branch so the VIP stays on the VLAN.
Address review feedback from coderabbitai on charts/generic/templates/_helpers.tpl:152.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
---------
Signed-off-by: Aleksei Sviridkin <f@lex.la>1 parent 397f32f commit 00358fd
8 files changed
Lines changed: 1321 additions & 87 deletions
File tree
- charts
- cozystack/templates
- generic/templates
- pkg/engine
- helm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
2 | 11 | | |
3 | 12 | | |
4 | 13 | | |
| |||
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
17 | | - | |
18 | | - | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| |||
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
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 | | - | |
| 73 | + | |
115 | 74 | | |
| 75 | + | |
| 76 | + | |
116 | 77 | | |
117 | 78 | | |
118 | 79 | | |
| |||
161 | 122 | | |
162 | 123 | | |
163 | 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 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 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 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
0 commit comments