Skip to content

Commit 5a35f2b

Browse files
diagnostic back
1 parent 1d6004d commit 5a35f2b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

stack_diagnostic.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package tfe
5+
6+
// StackDiagnostic represents any sourcebundle.Diagnostic value. The simplest form has
7+
// just a severity, single line summary, and optional detail. If there is more
8+
// information about the source of the diagnostic, this is represented in the
9+
// range field.
10+
type StackDiagnostic struct {
11+
Severity string `jsonapi:"attr,severity"`
12+
Summary string `jsonapi:"attr,summary"`
13+
Detail string `jsonapi:"attr,detail"`
14+
Range *DiagnosticRange `jsonapi:"attr,range"`
15+
}
16+
17+
// DiagnosticPos represents a position in the source code.
18+
type DiagnosticPos struct {
19+
// Line is a one-based count for the line in the indicated file.
20+
Line int `jsonapi:"attr,line"`
21+
22+
// Column is a one-based count of Unicode characters from the start of the line.
23+
Column int `jsonapi:"attr,column"`
24+
25+
// Byte is a zero-based offset into the indicated file.
26+
Byte int `jsonapi:"attr,byte"`
27+
}
28+
29+
// DiagnosticRange represents the filename and position of the diagnostic
30+
// subject. This defines the range of the source to be highlighted in the
31+
// output. Note that the snippet may include additional surrounding source code
32+
// if the diagnostic has a context range.
33+
//
34+
// The stacks-specific source field represents the full source bundle address
35+
// of the file, while the filename field is the sub path relative to its
36+
// enclosing package. This represents an attempt to be somewhat backwards
37+
// compatible with the existing Terraform JSON diagnostic format, where
38+
// filename is root module relative.
39+
//
40+
// The Start position is inclusive, and the End position is exclusive. Exact
41+
// positions are intended for highlighting for human interpretation only and
42+
// are subject to change.
43+
type DiagnosticRange struct {
44+
Filename string `jsonapi:"attr,filename"`
45+
Source string `jsonapi:"attr,source"`
46+
Start DiagnosticPos `jsonapi:"attr,start"`
47+
End DiagnosticPos `jsonapi:"attr,end"`
48+
}

0 commit comments

Comments
 (0)