-
Notifications
You must be signed in to change notification settings - Fork 1
/
buf.go
62 lines (56 loc) · 1.29 KB
/
buf.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
package main
import (
"fmt"
"strings"
)
func makeBufYaml(project string) []byte {
content := fmt.Sprintf(`
version: v1
name: buf.build/%s
deps:
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
ignore_unstable_packages: true
lint:
use:
- DEFAULT
`, project)
content = strings.Replace(content, "\t", " ", -1)
return []byte(strings.Trim(content, "\n"))
}
func makeBufWorkYaml() []byte {
content := `
version: v1
directories:
- api-spec/protobuf
`
content = strings.Replace(content, "\t", " ", -1)
return []byte(strings.Trim(content, "\n"))
}
func makeBufGenYaml(module string) []byte {
content := fmt.Sprintf(`
version: v1
managed:
enabled: true
go_package_prefix:
default: %s/api-spec/protobuf/gen
plugins:
# Golang
- remote: buf.build/protocolbuffers/plugins/go
out: api-spec/protobuf/gen/go
opt: paths=source_relative
- remote: buf.build/grpc/plugins/go
out: api-spec/protobuf/gen/go
opt: paths=source_relative,require_unimplemented_servers=false
- remote: buf.build/grpc-ecosystem/plugins/grpc-gateway
out: api-spec/protobuf/gen
opt: paths=source_relative
#OpenApi
- remote: buf.build/grpc-ecosystem/plugins/openapiv2
out: api-spec/openapi/swagger
`, module)
content = strings.Replace(content, "\t", " ", -1)
return []byte(strings.Trim(content, "\n"))
}