Commit c8b3ac3
committed
fix: Correct validation logic and improve generator error handling
- Fix validation bug in templates/main.tmpl: change '>' to '>=' for min_length
comparison. This bug caused names that are exactly min_length characters to
be incorrectly marked as invalid.
- Add error handling for ExecuteTemplate() calls in main.go (lines 87, 92).
Previously, errors were silently ignored.
- Add defer file.Close() after opening mainFile and outputsFile for proper
resource cleanup.
- Add duplicate resource detection: check for duplicate resource names when
merging resourceDefinition.json and resourceDefinition_out_of_docs.json.
Log fatal error if duplicates are found.
- Add validation for required fields (name, slug, length with valid min/max)
before template execution. Clear error messages are logged for invalid
entries.
- Regenerated main.tf with the corrected validation logic.
Closes #1871 parent a837381 commit c8b3ac3
3 files changed
Lines changed: 361 additions & 301 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
30 | 31 | | |
31 | 32 | | |
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 | + | |
33 | 57 | | |
34 | 58 | | |
35 | 59 | | |
| |||
63 | 87 | | |
64 | 88 | | |
65 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
66 | 97 | | |
67 | 98 | | |
68 | 99 | | |
| |||
73 | 104 | | |
74 | 105 | | |
75 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
76 | 127 | | |
77 | 128 | | |
78 | 129 | | |
| |||
84 | 135 | | |
85 | 136 | | |
86 | 137 | | |
87 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
88 | 144 | | |
89 | 145 | | |
90 | 146 | | |
91 | 147 | | |
92 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
93 | 153 | | |
0 commit comments