forked from k8sgateway/k8sgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.go
76 lines (70 loc) · 2.41 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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/schemagen"
"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{
"github.com/solo-io/gloo/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,
ValidationSchemaOptions: &schemagen.ValidationSchemaOptions{
CrdDirectory: "install/helm/gloo/crds",
JsonSchemaTool: "protoc",
RemoveDescriptionsFromSchema: true,
EnumAsIntOrString: true,
MessagesWithEmptySchema: []string{
// These messages are recursive, and will cause codegen to enter an infinite loop
"core.solo.io.Status",
"ratelimit.api.solo.io.Descriptor",
"als.options.gloo.solo.io.AndFilter",
"als.options.gloo.solo.io.OrFilter",
// These messages are part of our internal API, and therefore aren't required
// Also they are quite large and can cause the Proxy CRD to become too large,
// resulting in: https://github.com/solo-io/gloo/issues/4789
"gloo.solo.io.HttpListener",
"gloo.solo.io.TcpListener",
"gloo.solo.io.HybridListener",
"gloo.solo.io.AggregateListener",
},
},
}
if err := cmd.Generate(generateOptions); err != nil {
log.Fatalf("generate failed!: %v", err)
}
log.Printf("finished generating code")
}