Commit 1ef4913
fix: retention_days validation logic for backward compatibility (#283)
* fix: retention_days validation logic for backward compatibility
The retention_days_cross_valid validation was causing 'argument must not be null'
errors in Terraform 1.6.0-1.11.4 and OpenTofu 1.6.0-1.9.3 when both min_retention_days
and max_retention_days were null (valid for standard vaults).
Changed from logical OR to conditional expression to handle null values properly:
- Returns true if either value is null (valid for standard vaults)
- Only performs min <= max comparison when both values are provided
- Maintains existing validation for air-gapped vaults via airgapped_vault_requirements_met
This ensures backward compatibility with older Terraform/OpenTofu versions while
preserving functionality for newer versions.
Fixes #281
Co-authored-by: Luis M. Gallardo D. <lgallard@users.noreply.github.com>
* refactor: improve retention_days_cross_valid clarity and add version compatibility docs
This commit builds on the fix from PR #283 with two improvements:
1. Clarify validation logic in main.tf:20
- Change from: (var.min_retention_days == null || var.max_retention_days == null) ? true : ...
- Change to: (var.min_retention_days != null && var.max_retention_days != null) ? (...) : true
- This explicit ternary pattern makes intent clearer: "compare only when both non-null"
- Improves code readability and maintainability for future developers
- Logically equivalent to original fix, with improved clarity
2. Document version compatibility in versions.tf
- Add comments explaining tested Terraform versions (1.3.0 - 1.11.4+)
- Add comments explaining tested OpenTofu versions (1.6.0 - 1.9.3+)
- Document the null handling issue fixed in main.tf
- Help users understand version support boundaries
These improvements maintain all existing functionality while enhancing code clarity
and providing better documentation for future maintainers.
* docs: clarify retention_days_cross_valid logical equivalence
Add inline comments explaining:
- Why we use positive logic form (both not null)
- Logical equivalence to the alternative form
- Clearer intent of the expression
- Prevents future confusion about this intentional transformation
This responds to feedback about the validation logic by documenting
that both forms are mathematically equivalent via De Morgan's Law,
but our form is clearer for maintenance.
---------
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Luis M. Gallardo D. <lgallard@users.noreply.github.com>1 parent 44e99e3 commit 1ef4913
3 files changed
+43
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
315 | 345 | | |
316 | 346 | | |
317 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
1 | 10 | | |
2 | 11 | | |
3 | 12 | | |
| |||
0 commit comments