Skip to content

Commit

Permalink
Merge pull request Place1#137 from DasSkelett/cleanup
Browse files Browse the repository at this point in the history
Replace usage of deprecated github.com/golang/protobuf with google.golang.org/protobuf
  • Loading branch information
DasSkelett authored Apr 13, 2022
2 parents c06f94a + 979f0ff commit 2d5c2b7
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 300 deletions.
3 changes: 2 additions & 1 deletion cmd/migrate/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package migrate

import (
"github.com/pkg/errors"
"github.com/freifunkMUC/wg-access-server/internal/storage"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
)
Expand Down
6 changes: 3 additions & 3 deletions codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ mkdir -p "$OUT_DIR" || true

protoc \
-I proto/ \
proto/*.proto \
--go_opt=paths=source_relative \
--go_out="plugins=grpc:$OUT_DIR"
--go_out="$OUT_DIR" --go_opt=paths=source_relative \
--go-grpc_out="$OUT_DIR" --go-grpc_opt=paths=source_relative \
proto/*.proto
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/docker/libnetwork v0.8.0-dev.2.0.20200217033114-6659f7f4d8c1
github.com/freifunkMUC/pg-events v0.4.0
github.com/freifunkMUC/wg-embed v0.7.0
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/gorilla/sessions v1.2.1
Expand All @@ -26,7 +25,7 @@ require (
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211207222515-92d582e4e166
google.golang.org/grpc v1.45.0
google.golang.org/protobuf v1.27.1
google.golang.org/protobuf v1.28.0
gopkg.in/Knetic/govaluate.v2 v2.3.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -41,6 +40,7 @@ require (
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/docker/docker v20.10.8+incompatible // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/Knetic/govaluate.v2 v2.3.0 h1:naJVc9CZlWA8rC8f5mvECJD7jreTrn7FvGXjBthkHJQ=
gopkg.in/Knetic/govaluate.v2 v2.3.0/go.mod h1:NW0gr10J8s7aNghEg6uhdxiEaBvc0+8VgJjVViHUKp4=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
Expand Down
11 changes: 5 additions & 6 deletions internal/services/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ package services
import (
"time"

"github.com/golang/protobuf/ptypes/timestamp"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

func TimestampToTime(value *timestamp.Timestamp) time.Time {
func TimestampToTime(value *timestamppb.Timestamp) time.Time {
return time.Unix(value.Seconds, int64(value.Nanos))
}

func TimeToTimestamp(value *time.Time) *timestamp.Timestamp {
func TimeToTimestamp(value *time.Time) *timestamppb.Timestamp {
if value == nil {
return nil
}
Expand All @@ -25,9 +24,9 @@ func TimeToTimestamp(value *time.Time) *timestamp.Timestamp {
return t
}

func stringValue(value *string) *wrappers.StringValue {
func stringValue(value *string) *wrapperspb.StringValue {
if value != nil {
return &wrappers.StringValue{
return &wrapperspb.StringValue{
Value: *value,
}
}
Expand Down
7 changes: 4 additions & 3 deletions internal/services/device_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"github.com/freifunkMUC/wg-access-server/pkg/authnz/authsession"
"github.com/freifunkMUC/wg-access-server/proto/proto"

"github.com/golang/protobuf/ptypes/empty"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
)

type DeviceService struct {
proto.UnimplementedDevicesServer
DeviceManager *devices.DeviceManager
}

Expand Down Expand Up @@ -49,7 +50,7 @@ func (d *DeviceService) ListDevices(ctx context.Context, req *proto.ListDevicesR
}, nil
}

func (d *DeviceService) DeleteDevice(ctx context.Context, req *proto.DeleteDeviceReq) (*empty.Empty, error) {
func (d *DeviceService) DeleteDevice(ctx context.Context, req *proto.DeleteDeviceReq) (*emptypb.Empty, error) {
user, err := authsession.CurrentUser(ctx)
if err != nil {
return nil, status.Errorf(codes.PermissionDenied, "not authenticated")
Expand All @@ -70,7 +71,7 @@ func (d *DeviceService) DeleteDevice(ctx context.Context, req *proto.DeleteDevic
return nil, status.Errorf(codes.Internal, "failed to delete device")
}

return &empty.Empty{}, nil
return &emptypb.Empty{}, nil
}

func (d *DeviceService) ListAllDevices(ctx context.Context, req *proto.ListAllDevicesReq) (*proto.ListAllDevicesRes, error) {
Expand Down
1 change: 1 addition & 0 deletions internal/services/server_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

type ServerService struct {
proto.UnimplementedServerServer
Config *config.AppConfig
Wg wgembed.WireGuardInterface
}
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"path/filepath"
"runtime"

"github.com/pkg/errors"
"github.com/freifunkMUC/wg-access-server/cmd"
"github.com/freifunkMUC/wg-access-server/cmd/migrate"
"github.com/freifunkMUC/wg-access-server/cmd/serve"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/authnz/authruntime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package authruntime
import (
"net/http"

"github.com/freifunkMUC/wg-access-server/pkg/authnz/authsession"

"github.com/gorilla/mux"
"github.com/gorilla/sessions"
"github.com/freifunkMUC/wg-access-server/pkg/authnz/authsession"
)

type Provider struct {
Expand Down
5 changes: 3 additions & 2 deletions proto/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ RUN npm ci --no-audit --prefer-offline
# Mount ./website/src/sdk to /code/src/sdk
CMD ["npm", "run", "codegen"]

FROM golang:1.17-alpine as proto-go
FROM golang:1.18-alpine as proto-go
RUN apk add --no-cache protobuf protobuf-dev
WORKDIR /code
RUN go install github.com/golang/protobuf/[email protected]
RUN go install google.golang.org/grpc/cmd/[email protected]
RUN go install google.golang.org/protobuf/cmd/[email protected]
# Mount ./proto to /code/proto
COPY ./codegen.sh ./
CMD ["./codegen.sh"]
196 changes: 1 addition & 195 deletions proto/proto/devices.pb.go

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

Loading

0 comments on commit 2d5c2b7

Please sign in to comment.