Skip to content

Commit 5f84115

Browse files
authored
remove usage of deprecated ptypes, fix linter issues (#46)
1 parent 0dd8131 commit 5f84115

File tree

24 files changed

+459
-299
lines changed

24 files changed

+459
-299
lines changed

.github/workflows/latest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Lint
2323
uses: golangci/golangci-lint-action@v2
2424
with:
25-
version: v1.32.2
25+
args: -p bugs -p unused
2626

2727
- name: Build and push Docker image
2828
run: |

.github/workflows/pull_request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Lint
2828
uses: golangci/golangci-lint-action@v2
2929
with:
30-
version: v1.32.2
30+
args: -p bugs -p unused
3131

3232
- name: Build Docker image
3333
run: |

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Lint
2323
uses: golangci/golangci-lint-action@v2
2424
with:
25-
version: v1.32.2
25+
args: -p bugs -p unused
2626

2727
- name: Build the Docker images
2828
run: |

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM alpine:3.12 as health-downloader
2-
ENV GRPC_HEALTH_PROBE_VERSION=v0.3.6 \
1+
FROM alpine:3.13 as health-downloader
2+
ENV GRPC_HEALTH_PROBE_VERSION=v0.4.2 \
33
GRPC_HEALTH_PROBE_URL=https://github.com/grpc-ecosystem/grpc-health-probe/releases/download
44
RUN apk -U add curl \
55
&& curl -fLso /bin/grpc_health_probe \

api/grpc/health/v1/health.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/rest/mapper/mapper.go

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package mapper
33
import (
44
"time"
55

6-
px "github.com/golang/protobuf/ptypes"
7-
"github.com/golang/protobuf/ptypes/timestamp"
8-
"github.com/golang/protobuf/ptypes/wrappers"
96
v1 "github.com/metal-stack/masterdata-api/api/rest/v1"
107
mdmv1 "github.com/metal-stack/masterdata-api/api/v1"
8+
"google.golang.org/protobuf/types/known/timestamppb"
119
"google.golang.org/protobuf/types/known/wrapperspb"
1210
)
1311

@@ -152,7 +150,7 @@ func ToMdmV1Quota(q *v1.Quota) *mdmv1.Quota {
152150
}
153151

154152
return &mdmv1.Quota{
155-
Quota: &wrappers.Int32Value{
153+
Quota: &wrapperspb.Int32Value{
156154
Value: *q.Quota,
157155
},
158156
}
@@ -234,43 +232,19 @@ func ToV1Quota(q *mdmv1.Quota) *v1.Quota {
234232
Quota: unwrapInt32(q.Quota),
235233
}
236234
}
237-
func unwrapInt32(w *wrappers.Int32Value) *int32 {
235+
func unwrapInt32(w *wrapperspb.Int32Value) *int32 {
238236
if w == nil {
239237
return nil
240238
}
241239

242240
return &w.Value
243241
}
244242

245-
func mustTimestampToTime(ts *timestamp.Timestamp) *time.Time {
246-
t, err := timestampToTime(ts)
247-
if err != nil {
248-
t = nil
249-
}
250-
return t
251-
}
252-
253-
func timestampToTime(ts *timestamp.Timestamp) (*time.Time, error) {
254-
if ts == nil {
255-
return nil, nil
256-
}
257-
258-
t, err := px.Timestamp(ts)
259-
return &t, err
243+
func mustTimestampToTime(ts *timestamppb.Timestamp) *time.Time {
244+
t := ts.AsTime()
245+
return &t
260246
}
261247

262-
func mustTimeToTimestamp(t *time.Time) *timestamp.Timestamp {
263-
ts, err := timeToTimestamp(t)
264-
if err != nil {
265-
ts = nil
266-
}
267-
return ts
268-
}
269-
270-
func timeToTimestamp(t *time.Time) (*timestamp.Timestamp, error) {
271-
if t == nil {
272-
return nil, nil
273-
}
274-
275-
return px.TimestampProto(*t)
248+
func mustTimeToTimestamp(t *time.Time) *timestamppb.Timestamp {
249+
return timestamppb.New(*t)
276250
}

api/rest/mapper/mapper_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package mapper
22

33
import (
4-
"github.com/google/go-cmp/cmp"
5-
v1 "github.com/metal-stack/masterdata-api/api/rest/v1"
64
"reflect"
75
"testing"
86
"time"
7+
8+
"github.com/google/go-cmp/cmp"
9+
v1 "github.com/metal-stack/masterdata-api/api/rest/v1"
910
)
1011

1112
func TestTenantMapperRoundtrip(t *testing.T) {
@@ -98,6 +99,7 @@ func TestTenantMapperRoundtrip(t *testing.T) {
9899
},
99100
}
100101
for _, tt := range tests {
102+
tt := tt
101103
t.Run(tt.name, func(t *testing.T) {
102104

103105
gotMdMV1 := ToMdmV1Tenant(tt.inAndOut)

api/v1/iam.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1/meta.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package v1
22

33
import (
4-
"github.com/golang/protobuf/ptypes/timestamp"
54
jsoniter "github.com/json-iterator/go"
5+
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
66
)
77

88
var json = jsoniter.ConfigCompatibleWithStandardLibrary
@@ -15,11 +15,11 @@ func (m *Meta) SetVersion(version int64) {
1515
m.Version = version
1616
}
1717

18-
func (m *Meta) SetCreatedTime(time *timestamp.Timestamp) {
18+
func (m *Meta) SetCreatedTime(time *timestamppb.Timestamp) {
1919
m.CreatedTime = time
2020
}
2121

22-
func (m *Meta) SetUpdatedTime(time *timestamp.Timestamp) {
22+
func (m *Meta) SetUpdatedTime(time *timestamppb.Timestamp) {
2323
m.UpdatedTime = time
2424
}
2525

api/v1/meta.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)