Skip to content

Commit

Permalink
Migrate to buf v2 (#4)
Browse files Browse the repository at this point in the history
* Migrate to buf v2

* Remove deprecated grpc client creation
  • Loading branch information
majst01 authored Jun 13, 2024
1 parent 2dbda54 commit de83d25
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 69 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.22"
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: setup buf
uses: bufbuild/buf-setup-action@v1
with:
version: '1.29.0'

- name: make
run: |
make
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ proto:
.PHONY: mocks
mocks:
rm -rf test/mocks
docker run --rm --user $$(id -u):$$(id -g) -w /work -v ${PWD}:/work vektra/mockery:v2.42.0 --keeptree --all --dir pkg/apis --output test/mocks
docker run --rm --user $$(id -u):$$(id -g) -w /work -v ${PWD}:/work vektra/mockery:v2.43.2 --keeptree --all --dir pkg/apis --output test/mocks

.PHONY: test
test:
Expand Down
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ go 1.22

require (
github.com/stretchr/testify v1.9.0
golang.org/x/net v0.22.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
golang.org/x/net v0.26.0
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.2
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
26 changes: 12 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -10,18 +8,18 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 h1:9IZDv+/GcI6u+a4jRFRLxQs0RUCfavGfoOgEW6jpkI0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs=
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 h1:9Xyg6I9IWQZhRVfCWjKK+l6kI0jHcPesVlMnT//aHNo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/v1/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/apis/v1/partition.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions pkg/apis/v1/s3_user.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions pkg/s3-api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
v1 "github.com/fi-ts/s3-go/pkg/apis/v1"
healthv1 "google.golang.org/grpc/health/grpc_health_v1"

"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
Expand All @@ -25,7 +24,7 @@ type client struct {
conn *grpc.ClientConn
}

func NewClient(ctx context.Context, hostname string, port int, certFile string, keyFile string, caFile string) (S3Client, error) {
func NewClient(hostname string, port int, certFile string, keyFile string, caFile string) (S3Client, error) {
address := fmt.Sprintf("%s:%d", hostname, port)

certPool, err := x509.SystemCertPool()
Expand Down Expand Up @@ -60,10 +59,9 @@ func NewClient(ctx context.Context, hostname string, port int, certFile string,
opts := []grpc.DialOption{
grpc.WithTransportCredentials(creds),
grpc.WithTransportCredentials(creds),
grpc.WithBlock(),
}

conn, err := grpc.DialContext(ctx, address, opts...)
conn, err := grpc.NewClient(address, opts...)
if err != nil {
return nil, err
}
Expand Down
18 changes: 15 additions & 3 deletions proto/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
MAKEFLAGS += --no-print-directory
BUF_VERSION := 1.32.2

_buf:
docker run --rm \
--entrypoint sh \
-v $(PWD)/..:/workspace \
-w /workspace/proto \
bufbuild/buf:$(BUF_VERSION) \
-c "buf $(CMD) && chown -R $(shell id -u):$(shell id -g) /workspace"


.PHONY: protolint
protolint:
buf format -w metalstack/io/s3/api/v1
buf lint -v
@$(MAKE) _buf CMD="format -w"
@$(MAKE) _buf CMD="lint -v"

.PHONY: protoc
protoc: protolint
buf generate -v
@$(MAKE) _buf CMD="generate -v"
11 changes: 4 additions & 7 deletions proto/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
version: v1
version: v2
plugins:
# generate go structs for protocol buffer definition
- plugin: buf.build/protocolbuffers/go:v1.33.0
- remote: buf.build/protocolbuffers/go:v1.34.2
out: ../
# generate gRPC stubs in golang
- plugin: buf.build/grpc/go:v1.3.0
- remote: buf.build/grpc/go:v1.3.0
out: ../
opt:
- require_unimplemented_servers=false
opt: require_unimplemented_servers=false
15 changes: 10 additions & 5 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
version: v1
breaking:
use:
- FILE
version: v2
lint:
use:
- DEFAULT
except:
# TODO remove these
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
- RPC_REQUEST_RESPONSE_UNIQUE
- RPC_REQUEST_STANDARD_NAME
- RPC_RESPONSE_STANDARD_NAME
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
2 changes: 1 addition & 1 deletion test/mocks/v1/S3PartitionServiceClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/mocks/v1/S3PartitionServiceServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/mocks/v1/S3UserServiceClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/mocks/v1/S3UserServiceServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/mocks/v1/UnsafeS3PartitionServiceServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/mocks/v1/UnsafeS3UserServiceServer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de83d25

Please sign in to comment.