forked from k8sgateway/k8sgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.go
54 lines (49 loc) · 1.45 KB
/
generate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"github.com/solo-io/go-utils/log"
"github.com/solo-io/solo-kit/pkg/code-generator/cmd"
"github.com/solo-io/solo-kit/pkg/code-generator/docgen/options"
"github.com/solo-io/solo-kit/pkg/code-generator/sk_anyvendor"
)
//go:generate go run generate.go
func main() {
log.Printf("starting generate")
protoImports := sk_anyvendor.CreateDefaultMatchOptions(
[]string{"projects/**/*.proto", sk_anyvendor.SoloKitMatchPattern},
)
protoImports.External["github.com/solo-io/solo-apis"] = []string{
"api/rate-limiter/**/*.proto", // Import rate limit API
"api/gloo-fed/fed/**/*.proto", // Import gloo fed gloo instance API
}
// Import gloo instance API dependencies
protoImports.External["github.com/solo-io/skv2"] = []string{
"api/**/**/*.proto",
}
generateOptions := cmd.GenerateOptions{
SkipGenMocks: true,
CustomCompileProtos: []string{
"projects/gloo/api/grpc",
},
SkipGeneratedTests: true,
// helps to cut down on time spent searching for imports, not strictly necessary
SkipDirs: []string{
"docs",
"test",
"projects/gloo/api/grpc",
},
RelativeRoot: ".",
CompileProtos: true,
GenDocs: &cmd.DocsOptions{
Output: options.Hugo,
HugoOptions: &options.HugoOptions{
DataDir: "/docs/data",
ApiDir: "reference/api",
},
},
ExternalImports: protoImports,
}
if err := cmd.Generate(generateOptions); err != nil {
log.Fatalf("generate failed!: %v", err)
}
log.Printf("finished generating code")
}