Skip to content

Commit

Permalink
Migrate from github.com/golang/protobuf to google.golang.org/protobuf (
Browse files Browse the repository at this point in the history
…#7593)

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Jul 16, 2024
1 parent 35c90f1 commit c69f47d
Show file tree
Hide file tree
Showing 23 changed files with 1,805 additions and 1,634 deletions.
3 changes: 0 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ linters:

issues:
exclude-rules:
- linters:
- staticcheck
text: "github.com/golang/protobuf/proto" # grpc-go still uses github.com/golang/protobuf/proto.
- linters:
- staticcheck
text: "DefaultVolumesToRestic" # No need to report deprecate for DefaultVolumesToRestic.
Expand Down
1 change: 1 addition & 0 deletions changelogs/unreleased/7593-mmorel-35
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Migrate from github.com/golang/protobuf to google.golang.org/protobuf
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/evanphx/json-patch/v5 v5.8.0
github.com/fatih/color v1.16.0
github.com/gobwas/glob v0.2.3
github.com/golang/protobuf v1.5.4
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-hclog v0.14.1
Expand Down Expand Up @@ -104,6 +103,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
Expand Down
3 changes: 2 additions & 1 deletion hack/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ RUN ARCH=$(go env GOARCH) && \
chmod a+x /usr/include/google/protobuf && \
chmod a+r -R /usr/include/google && \
chmod +x /usr/bin/protoc
RUN go install google.golang.org/protobuf/cmd/[email protected]
RUN go install google.golang.org/protobuf/cmd/[email protected] \
&& go install google.golang.org/grpc/cmd/[email protected]

# get goreleaser
# goreleaser name template per arch is basically goarch except for amd64 and 386 https://github.com/goreleaser/goreleaser/blob/ec8819a95c5527fae65e5cb41673f5bbc3245fda/.goreleaser.yaml#L167C1-L173C42
Expand Down
10 changes: 9 additions & 1 deletion hack/update-2proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ HACK_DIR=$(dirname "${BASH_SOURCE}")
echo "Updating plugin proto"

echo protoc --version
protoc pkg/plugin/proto/*.proto pkg/plugin/proto/*/*/*.proto --go_out=plugins=grpc:pkg/plugin/generated/ --go_opt=module=github.com/vmware-tanzu/velero/pkg/plugin/generated -I pkg/plugin/proto/ -I /usr/include
protoc \
-I pkg/plugin/proto/ \
-I /usr/include \
--go_out=pkg/plugin/generated/ \
--go_opt=module=github.com/vmware-tanzu/velero/pkg/plugin/generated \
--go-grpc_out=pkg/plugin/generated \
--go-grpc_opt=paths=source_relative \
--go-grpc_opt=require_unimplemented_servers=false \
$(find pkg/plugin/proto -name '*.proto')

echo "Updating plugin proto - done!"
6 changes: 3 additions & 3 deletions pkg/plugin/framework/common/server_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
package common

import (
goproto "github.com/golang/protobuf/proto"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/protoadapt"

proto "github.com/vmware-tanzu/velero/pkg/plugin/generated"
"github.com/vmware-tanzu/velero/pkg/util/logging"
Expand All @@ -32,7 +32,7 @@ import (
//
// This function should be used in the internal plugin server code to wrap
// all errors before they're returned.
func NewGRPCErrorWithCode(err error, code codes.Code, details ...goproto.Message) error {
func NewGRPCErrorWithCode(err error, code codes.Code, details ...protoadapt.MessageV1) error {
// if it's already a gRPC status error, use it; otherwise, create a new one
statusErr, ok := status.FromError(err)
if !ok {
Expand All @@ -54,7 +54,7 @@ func NewGRPCErrorWithCode(err error, code codes.Code, details ...goproto.Message

// NewGRPCError is a convenience function for creating a new gRPC error
// with code = codes.Unknown
func NewGRPCError(err error, details ...goproto.Message) error {
func NewGRPCError(err error, details ...protoadapt.MessageV1) error {
return NewGRPCErrorWithCode(err, codes.Unknown, details...)
}

Expand Down
129 changes: 2 additions & 127 deletions pkg/plugin/generated/BackupItemAction.pb.go

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

144 changes: 144 additions & 0 deletions pkg/plugin/generated/BackupItemAction_grpc.pb.go

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

Loading

0 comments on commit c69f47d

Please sign in to comment.