Skip to content

Commit f8a7187

Browse files
Check in generated code and update according to buf lint (#62)
* checking in generated code and updating according to buf lint * adding exception in buf lint for enums, removing org from package name * fixing enum name, and ENV_VARS.md * using go as package name for generated files, adding exception for enum in buf * chore: makes sure go gets generated and can be consume seamless. * chore: removes protolint. * chore: tweaks env var generation. * chore: fix replace directive. * updating package names, and exceptions in buf * chore: simplify packages. * chore: ignore directory structure for config.proto. * chore: adds go generated code from proto. * fix: sets the right go package * chore: improves the generated code and the generate command. * fix: sets the right make targets * chore: sets the right path for env vars generation * docs: update env vars. * chore: removes unused files in the generated code. * chore: fix loader for when default value for fields is nil. * chore: fixes pointer for loading options to avoid the copy of a lock field. * chore: improves the package structure by simplfying it and shorten it. Co-authored-by: José Carlos Chávez <[email protected]>
1 parent 56d8dec commit f8a7187

36 files changed

+2331
-39
lines changed

.github/workflows/linter.yml .github/workflows/pr.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ jobs:
88
- name: checkout source
99
uses: actions/checkout@v1
1010

11-
- name: run protolint
12-
uses: plexsystems/[email protected]
11+
- name: Install buf
12+
uses: wizhi/setup-buf@v1
1313
with:
14-
configDirectory: .
14+
version: 0.36.0
15+
16+
- name: Lint proto
17+
run: make lint-proto

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
.vscode
44
.idea
55
*~
6-
7-
# Generated code
8-
**/*.pb.go

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "tools/env-vars-generator/protobuf"]
22
path = tools/env-vars-generator/protobuf
33
url = https://github.com/protocolbuffers/protobuf.git
4+
[submodule "tools/go-generator/cmd/generator/_protobuf"]
5+
path = tools/go-generator/cmd/generator/_protobuf
6+
url = https://github.com/protocolbuffers/protobuf.git

.protolint.yaml

-20
This file was deleted.

ENV_VARS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Agents can be configured using environment variables:
2525
| HT_DATA_CAPTURE_BODY_MAX_SIZE_BYTES | Maximum size of captured body in bytes. Default should be 131_072 (128 KiB). |
2626
| HT_PROPAGATION_FORMATS | List the supported propagation formats e.g. `HT_PROPAGATION_FORMATS="B3,TRACECONTEXT"`. |
2727
| HT_ENABLED | When `false`, disables the agent |
28-
| HT_JAVAAGENT_FILTER_JAR_PATHS | Is the list of path to filter jars, separated by `,`. |
28+
| HT_JAVAAGENT_FILTER_JAR_PATHS | Is the list of path to filter jars, separated by `,`. The values should be separated by `,`. |

Makefile

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1-
.PHONY: default help lint generate-env-vars init-git-submodule
1+
.PHONY: default help lint-proto generate-env-vars init-git-submodule breaking-proto generate-proto clean
22

33
default: help
44

55
help: ## Prints this help.
66
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-18s\033[0m %s\n", $$1, $$2}'
77

8-
lint: ## Lints the proto files.
9-
protolint config.proto
8+
clean: ## Cleans all build generated artifacts
9+
rm -rf ./gen
10+
11+
install:
12+
go install -mod=mod \
13+
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
14+
google.golang.org/protobuf/cmd/protoc-gen-go \
15+
github.com/bufbuild/buf/cmd/buf
16+
17+
lint-proto:
18+
$(MAKE) -C ./proto lint
19+
20+
breaking-proto:
21+
$(MAKE) -C ./proto breaking
22+
23+
generate-proto:
24+
@# Generates pb struct
25+
$(MAKE) -C ./proto generate
26+
27+
@# Generates pb loaders
28+
@ROOT=$(PWD)/proto OUT_DIR=$(PWD)/gen/go \
29+
$(MAKE) -C ./tools/go-generator
30+
31+
@echo "Tidy generated modules."
32+
@find $(PWD)/gen/go \( -name vendor -o -name '[._].*' -o -name node_modules \) -prune -o -name go.mod -print | sed 's:/go.mod::' | xargs -I {} bash -c 'cd {}; go mod tidy'
1033

1134
generate-env-vars: init-git-submodule ## Generates the ENV_VARS.md with all environment variables.
1235
docker build -t hypertrace/agent-config/env-vars-generator tools/env-vars-generator
36+
touch $(PWD)/ENV_VARS.md # makes sure this is created as a file and not as a directory
1337
docker run \
1438
-v $(PWD)/ENV_VARS.md:/usr/local/ENV_VARS.md \
15-
-v $(PWD)/config.proto:/usr/local/config.proto \
39+
-v $(PWD)/proto/hypertrace/agent/config/v1/config.proto:/usr/local/config.proto \
1640
hypertrace/agent-config/env-vars-generator \
1741
-o /usr/local/ENV_VARS.md \
1842
/usr/local/config.proto

gen/go/go.mod

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/hypertrace/agent-config/gen/go
2+
3+
go 1.16
4+
5+
require (
6+
github.com/ghodss/yaml v1.0.0
7+
github.com/golang/protobuf v1.5.2
8+
github.com/stretchr/testify v1.7.0
9+
google.golang.org/protobuf v1.27.1
10+
gopkg.in/yaml.v2 v2.4.0 // indirect
11+
)

gen/go/go.sum

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
4+
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
5+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
6+
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
7+
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
8+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
9+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
10+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
11+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
12+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
13+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
14+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
15+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
16+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
17+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
18+
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
19+
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
20+
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
21+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
22+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
23+
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
24+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
25+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
26+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)