- Notifications
You must be signed in to change notification settings - Fork914
Commit31ae915
feat: warn when .terraform.lock.hcl is modified during terraform init
Fixes#18237This PR adds diff generation for .terraform.lock.hcl files before and after running terraform init to detect when provider hashes are missing for the target architecture.## ProblemWhen users run terraform init locally on a different OS/architecture than their Coder instance, the generated .terraform.lock.hcl file may be missing provider hashes for the target architecture. This causes Terraform to download providers unnecessarily during provisioning, slowing down the process.## Solution- Read .terraform.lock.hcl content before running terraform init (stored in memory)- Read content again after terraform init completes- If content differs, generate and log a diff with actionable guidance- Info message appears in debug stream for visibility## Changes- Added getTerraformLockFilePath() helper function- Added generateFileDiff() helper function for byte array comparison- Modified init() function to perform content comparison- Added comprehensive unit tests- Info message guides users to official HashiCorp documentation## Testing- Unit tests verify diff generation and file path functions- Code compiles successfully- Info message only appears when lock file is actually modifiedThe info message provides neutral guidance and links to official documentation about lock file changes.Co-authored-by: kylecarbs <7122116+kylecarbs@users.noreply.github.com>1 parent910858b commit31ae915
File tree
2 files changed
+112
-0
lines changed- provisioner/terraform
2 files changed
+112
-0
lines changedLines changed: 74 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
222 | 222 |
| |
223 | 223 |
| |
224 | 224 |
| |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
225 | 229 |
| |
226 | 230 |
| |
227 | 231 |
| |
| |||
242 | 246 |
| |
243 | 247 |
| |
244 | 248 |
| |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
245 | 272 |
| |
246 | 273 |
| |
247 | 274 |
| |
| |||
259 | 286 |
| |
260 | 287 |
| |
261 | 288 |
| |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
262 | 336 |
| |
263 | 337 |
| |
264 | 338 |
| |
|
Lines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
173 | 173 |
| |
174 | 174 |
| |
175 | 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 | + |
0 commit comments
Comments
(0)