@@ -3,7 +3,8 @@ package apitypes
33import (
44 "time"
55
6- "github.com/coder/preview"
6+ "github.com/hashicorp/hcl/v2"
7+
78 "github.com/coder/preview/types"
89)
910
@@ -33,14 +34,19 @@ const (
3334)
3435
3536type PreviewOutput struct {
36- Output * preview. Output `json:"output"`
37+ Output * Output `json:"output"`
3738 Diags types.Diagnostics `json:"diags"`
3839 // ParserLogs are trivy logs that occur during parsing the
3940 // Terraform files. This is useful for debugging issues with the
4041 // invalid terraform syntax.
4142 ParserLogs []ParserLog `json:"parser_logs,omitempty"`
4243}
4344
45+ type Output struct {
46+ Parameters []ParameterWithSource `json:"parameters"`
47+ Files map [string ]* hcl.File `json:"files"`
48+ }
49+
4450type ParserLog struct {
4551 Time time.Time `json:"time"`
4652 Level string `json:"level"`
@@ -53,3 +59,24 @@ type ParserLog struct {
5359type NullHCLString = types.NullHCLString
5460
5561type FriendlyDiagnostic = types.FriendlyDiagnostic
62+
63+ type ParameterWithSource struct {
64+ types.Parameter
65+ TypeRange hcl.Range `json:"type_range"`
66+ }
67+
68+ func WithSource (p []types.Parameter ) []ParameterWithSource {
69+ result := make ([]ParameterWithSource , 0 , len (p ))
70+ for _ , param := range p {
71+ src := ParameterWithSource {
72+ Parameter : param ,
73+ }
74+
75+ if param .Source != nil {
76+ src .TypeRange = param .Source .HCLBlock ().TypeRange
77+ }
78+
79+ result = append (result , src )
80+ }
81+ return result
82+ }
0 commit comments