Skip to content

Commit

Permalink
ROX-22019: Protobuf v2 migration (#1500)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtodor authored Jul 23, 2024
1 parent 6ddbf39 commit 9da484b
Show file tree
Hide file tree
Showing 49 changed files with 18,977 additions and 15,647 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ generate-junit-reports: $(GO_JUNIT_REPORT_BIN)
## Generated Srcs ##
####################

PROTO_GENERATED_SRCS = $(GENERATED_PB_SRCS) $(GENERATED_API_GW_SRCS)
PROTO_GENERATED_SRCS = $(GENERATED_PB_SRCS) $(GENERATED_VT_SRCS) $(GENERATED_API_SRCS) $(GENERATED_API_GW_SRCS)

include make/protogen.mk

Expand Down Expand Up @@ -525,7 +525,7 @@ local-nodescanner:
$(BUILD_FLAGS) $(NODESCAN_BUILD_CMD)

.PHONY: local-nodescanner-build-dockerized
local-nodescanner-build-dockerized:
local-nodescanner-build-dockerized:
@echo "+ $@"
ifdef CI
docker container create --name builder $(BUILD_IMAGE) $(NODESCAN_BUILD_CMD)
Expand Down
4 changes: 2 additions & 2 deletions api/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/NYTimes/gziphandler"
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
log "github.com/sirupsen/logrus"
"github.com/stackrox/scanner/pkg/env"
"github.com/stackrox/scanner/pkg/mtls"
Expand Down Expand Up @@ -190,7 +190,7 @@ func (a *apiImpl) muxer(localConn *grpc.ClientConn) http.Handler {
mux.Handle(route, handler)
}

gwMux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{EmitDefaults: true}))
gwMux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{}))
for _, service := range a.apiServices {
if err := service.RegisterServiceHandler(context.Background(), gwMux, localConn); err != nil {
log.Panicf("failed to register API service: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion api/v1/imagescan/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package imagescan
import (
"context"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/sirupsen/logrus"
"github.com/stackrox/rox/pkg/stringutils"
apiGRPC "github.com/stackrox/scanner/api/grpc"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/nodeinventory/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"time"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
apiGRPC "github.com/stackrox/scanner/api/grpc"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/nodescan/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sort"
"strings"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/stackrox/rox/pkg/stringutils"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/orchestratorscan/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package orchestratorscan
import (
"context"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
rpmVersion "github.com/knqyf263/go-rpm-version"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion api/v1/ping/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ping
import (
"context"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
apiGRPC "github.com/stackrox/scanner/api/grpc"
v1 "github.com/stackrox/scanner/generated/scanner/api/v1"
"github.com/stackrox/scanner/pkg/version"
Expand Down
8 changes: 4 additions & 4 deletions api/v1/vulndefs/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package vulndefs
import (
"context"

"github.com/gogo/protobuf/types"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
apiGRPC "github.com/stackrox/scanner/api/grpc"
"github.com/stackrox/scanner/database"
v1 "github.com/stackrox/scanner/generated/scanner/api/v1"
"github.com/stackrox/scanner/pkg/updater"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)

// Service defines a vulnerability definitions service.
Expand Down Expand Up @@ -50,8 +50,8 @@ func (s *serviceImpl) GetVulnDefsMetadata(context.Context, *v1.Empty) (*v1.VulnD
return nil, status.Errorf(codes.Internal, "failed to obtain vulnerability definitions update timestamp: %v", err)
}

ts, err := types.TimestampProto(t)
if err != nil {
ts := timestamppb.New(t)
if err = ts.CheckValid(); err != nil {
return nil, status.Errorf(codes.Internal, "failed to obtain vulnerability definitions update timestamp: %v", err)
}

Expand Down
Loading

0 comments on commit 9da484b

Please sign in to comment.