30
30
}
31
31
)
32
32
33
+ var protoFiles = []string {
34
+ "pkg/iac/scanners/terraformplan/snapshot/planproto/planfile.proto" ,
35
+ }
36
+
33
37
func init () {
34
38
slog .SetDefault (log .New (log .NewHandler (os .Stderr , nil ))) // stdout is suppressed in mage
35
39
}
@@ -154,11 +158,11 @@ func Mock(dir string) error {
154
158
func Protoc () error {
155
159
// It is called in the protoc container
156
160
if _ , ok := os .LookupEnv ("TRIVY_PROTOC_CONTAINER" ); ok {
157
- protoFiles , err := findProtoFiles ()
161
+ rpcProtoFiles , err := findRPCProtoFiles ()
158
162
if err != nil {
159
163
return err
160
164
}
161
- for _ , file := range protoFiles {
165
+ for _ , file := range rpcProtoFiles {
162
166
// Check if the generated Go file is up-to-date
163
167
dst := strings .TrimSuffix (file , ".proto" ) + ".pb.go"
164
168
if updated , err := target .Path (dst , file ); err != nil {
@@ -173,6 +177,13 @@ func Protoc() error {
173
177
return err
174
178
}
175
179
}
180
+
181
+ for _ , file := range protoFiles {
182
+ if err := sh .RunV ("protoc" , "." , "paths=source_relative" , "--go_out" , "." , "--go_opt" ,
183
+ "paths=source_relative" , file ); err != nil {
184
+ return err
185
+ }
186
+ }
176
187
return nil
177
188
}
178
189
@@ -331,11 +342,13 @@ func Fmt() error {
331
342
}
332
343
333
344
// Format proto files
334
- protoFiles , err := findProtoFiles ()
345
+ rpcProtoFiles , err := findRPCProtoFiles ()
335
346
if err != nil {
336
347
return err
337
348
}
338
- for _ , file := range protoFiles {
349
+
350
+ allProtoFiles := append (protoFiles , rpcProtoFiles ... )
351
+ for _ , file := range allProtoFiles {
339
352
if err = sh .Run ("clang-format" , "-i" , file ); err != nil {
340
353
return err
341
354
}
@@ -422,7 +435,7 @@ func (Docs) Generate() error {
422
435
return sh .RunWith (ENV , "go" , "run" , "-tags=mage_docs" , "./magefiles" )
423
436
}
424
437
425
- func findProtoFiles () ([]string , error ) {
438
+ func findRPCProtoFiles () ([]string , error ) {
426
439
var files []string
427
440
err := filepath .WalkDir ("rpc" , func (path string , d fs.DirEntry , err error ) error {
428
441
switch {
0 commit comments