mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-01-24 08:00:27 -05:00
Now that we have a comprehensive JSON diagnostic structure, we can use it in the `validate -json` output instead of the inline version. Note that this changes the output of `validate -json` in two ways: 1. We fix some off-by-one errors caused by zero-width highlight ranges. This aligns the JSON diagnostic output with the text output seen by most Terraform users, so I consider this a bug fix. 2. We add the `snippet` field to the JSON diagnostics where available. This is purely additive and is permitted under our JSON format stability guarantees.
60 lines
1.5 KiB
JSON
60 lines
1.5 KiB
JSON
{
|
|
"valid": false,
|
|
"error_count": 2,
|
|
"warning_count": 0,
|
|
"diagnostics": [
|
|
{
|
|
"severity": "error",
|
|
"summary": "Duplicate module call",
|
|
"detail": "A module call named \"multi_module\" was already defined at testdata/validate-invalid/multiple_modules/main.tf:1,1-22. Module calls must have unique names within a module.",
|
|
"range": {
|
|
"filename": "testdata/validate-invalid/multiple_modules/main.tf",
|
|
"start": {
|
|
"line": 5,
|
|
"column": 1,
|
|
"byte": 46
|
|
},
|
|
"end": {
|
|
"line": 5,
|
|
"column": 22,
|
|
"byte": 67
|
|
}
|
|
},
|
|
"snippet": {
|
|
"context": null,
|
|
"code": "module \"multi_module\" {",
|
|
"start_line": 5,
|
|
"highlight_start_offset": 0,
|
|
"highlight_end_offset": 21,
|
|
"values": []
|
|
}
|
|
},
|
|
{
|
|
"severity": "error",
|
|
"summary": "Module not installed",
|
|
"detail": "This module is not yet installed. Run \"terraform init\" to install all modules required by this configuration.",
|
|
"range": {
|
|
"filename": "testdata/validate-invalid/multiple_modules/main.tf",
|
|
"start": {
|
|
"line": 5,
|
|
"column": 1,
|
|
"byte": 46
|
|
},
|
|
"end": {
|
|
"line": 5,
|
|
"column": 22,
|
|
"byte": 67
|
|
}
|
|
},
|
|
"snippet": {
|
|
"context": null,
|
|
"code": "module \"multi_module\" {",
|
|
"start_line": 5,
|
|
"highlight_start_offset": 0,
|
|
"highlight_end_offset": 21,
|
|
"values": []
|
|
}
|
|
}
|
|
]
|
|
}
|