@@ -4,9 +4,12 @@ import (
44 "context"
55 "fmt"
66 "io/fs"
7+ "log/slog"
8+ "os"
79 "path/filepath"
810
911 "github.com/aquasecurity/trivy/pkg/iac/scanners/terraform/parser"
12+ "github.com/aquasecurity/trivy/pkg/log"
1013 "github.com/hashicorp/hcl/v2"
1114
1215 "github.com/coder/preview/types"
@@ -15,6 +18,7 @@ import (
1518type Input struct {
1619 PlanJSONPath string
1720 ParameterValues map [string ]string
21+ Owner types.WorkspaceOwner
1822}
1923
2024type Output struct {
@@ -24,6 +28,10 @@ type Output struct {
2428}
2529
2630func Preview (ctx context.Context , input Input , dir fs.FS ) (* Output , hcl.Diagnostics ) {
31+ // TODO: FIX LOGGING
32+ slog .SetLogLoggerLevel (slog .LevelDebug )
33+ slog .SetDefault (slog .New (log .NewHandler (os .Stderr , nil )))
34+
2735 varFiles , err := tfVarFiles ("" , dir )
2836 if err != nil {
2937 return nil , hcl.Diagnostics {
@@ -45,12 +53,27 @@ func Preview(ctx context.Context, input Input, dir fs.FS) (*Output, hcl.Diagnost
4553 },
4654 }
4755 }
56+
57+ ownerHook , err := WorkspaceOwnerHook (dir , input )
58+ if err != nil {
59+ return nil , hcl.Diagnostics {
60+ {
61+ Severity : hcl .DiagError ,
62+ Summary : "Workspace owner hook" ,
63+ Detail : err .Error (),
64+ },
65+ }
66+ }
67+ var _ = ownerHook
68+
4869 // moduleSource is "" for a local module
4970 p := parser .New (dir , "" ,
71+ parser .OptionStopOnHCLError (true ),
5072 parser .OptionWithDownloads (false ),
5173 parser .OptionWithTFVarsPaths (varFiles ... ),
5274 parser .OptionWithEvalHook (planHook ),
5375 parser .OptionWithEvalHook (ParameterContextsEvalHook (input )),
76+ parser .OptionWithEvalHook (ownerHook ),
5477 parser .OptionWithSkipCachedModules (true ),
5578 )
5679
0 commit comments