Skip to content

Commit 3e76528

Browse files
authored
build: upgrade protobuf library (#308)
1 parent 6fda4cc commit 3e76528

File tree

8 files changed

+3415
-2010
lines changed

8 files changed

+3415
-2010
lines changed

clients/restore/restore.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212
"strings"
1313
"time"
1414

15-
"github.com/gogo/protobuf/proto"
1615
"github.com/influxdata/influx-cli/v2/api"
1716
"github.com/influxdata/influx-cli/v2/clients"
1817
br "github.com/influxdata/influx-cli/v2/internal/backup_restore"
1918
"github.com/influxdata/influx-cli/v2/pkg/gzip"
19+
"google.golang.org/protobuf/proto"
2020
)
2121

2222
type ApiConfig interface {
@@ -329,7 +329,7 @@ func (c Client) restoreBucketLegacy(ctx context.Context, bkt br.ManifestBucketEn
329329
}
330330

331331
dbi := bucketToDBI(bkt)
332-
dbiBytes, err := proto.Marshal(&dbi)
332+
dbiBytes, err := proto.Marshal(dbi)
333333
if err != nil {
334334
return nil, err
335335
}
@@ -370,7 +370,7 @@ func (c Client) restoreOrg(ctx context.Context, name string) (string, error) {
370370
return *orgs.GetOrgs()[0].Id, nil
371371
}
372372

373-
func bucketToDBI(b br.ManifestBucketEntry) br.DatabaseInfo {
373+
func bucketToDBI(b br.ManifestBucketEntry) *br.DatabaseInfo {
374374
dbi := br.DatabaseInfo{
375375
Name: &b.BucketID,
376376
DefaultRetentionPolicy: &b.DefaultRetentionPolicy,
@@ -379,12 +379,12 @@ func bucketToDBI(b br.ManifestBucketEntry) br.DatabaseInfo {
379379
}
380380
for i, rp := range b.RetentionPolicies {
381381
converted := retentionPolicyToRPI(rp)
382-
dbi.RetentionPolicies[i] = &converted
382+
dbi.RetentionPolicies[i] = converted
383383
}
384-
return dbi
384+
return &dbi
385385
}
386386

387-
func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) br.RetentionPolicyInfo {
387+
func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) *br.RetentionPolicyInfo {
388388
replicaN := uint32(rp.ReplicaN)
389389
rpi := br.RetentionPolicyInfo{
390390
Name: &rp.Name,
@@ -396,7 +396,7 @@ func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) br.RetentionPolicyInfo
396396
}
397397
for i, sg := range rp.ShardGroups {
398398
converted := shardGroupToSGI(sg)
399-
rpi.ShardGroups[i] = &converted
399+
rpi.ShardGroups[i] = converted
400400
}
401401
for i, s := range rp.Subscriptions {
402402
converted := br.SubscriptionInfo{
@@ -406,10 +406,10 @@ func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) br.RetentionPolicyInfo
406406
}
407407
rpi.Subscriptions[i] = &converted
408408
}
409-
return rpi
409+
return &rpi
410410
}
411411

412-
func shardGroupToSGI(sg br.ManifestShardGroup) br.ShardGroupInfo {
412+
func shardGroupToSGI(sg br.ManifestShardGroup) *br.ShardGroupInfo {
413413
id := uint64(sg.ID)
414414
start := sg.StartTime.UnixNano()
415415
end := sg.EndTime.UnixNano()
@@ -430,12 +430,12 @@ func shardGroupToSGI(sg br.ManifestShardGroup) br.ShardGroupInfo {
430430
}
431431
for i, s := range sg.Shards {
432432
converted := shardToSI(s)
433-
sgi.Shards[i] = &converted
433+
sgi.Shards[i] = converted
434434
}
435-
return sgi
435+
return &sgi
436436
}
437437

438-
func shardToSI(shard br.ManifestShardEntry) br.ShardInfo {
438+
func shardToSI(shard br.ManifestShardEntry) *br.ShardInfo {
439439
id := uint64(shard.ID)
440440
si := br.ShardInfo{
441441
ID: &id,
@@ -446,7 +446,7 @@ func shardToSI(shard br.ManifestShardEntry) br.ShardInfo {
446446
converted := br.ShardOwner{NodeID: &oid}
447447
si.Owners[i] = &converted
448448
}
449-
return si
449+
return &si
450450
}
451451

452452
// readFileGzipped opens a local file and returns a reader of its contents,

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
github.com/fatih/color v1.9.0
1111
github.com/fujiwara/shapeio v1.0.0
1212
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d
13-
github.com/gogo/protobuf v1.3.2
1413
github.com/golang/mock v1.5.0
1514
github.com/google/go-jsonnet v0.17.0
1615
github.com/mattn/go-isatty v0.0.13
@@ -20,6 +19,7 @@ require (
2019
go.etcd.io/bbolt v1.3.6
2120
golang.org/x/text v0.3.3
2221
golang.org/x/tools v0.1.0
22+
google.golang.org/protobuf v1.27.1
2323
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
2424
honnef.co/go/tools v0.2.0
2525
)

go.sum

+6-10
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ github.com/fujiwara/shapeio v1.0.0 h1:xG5D9oNqCSUUbryZ/jQV3cqe1v2suEjwPIcEg1gKM8
2121
github.com/fujiwara/shapeio v1.0.0/go.mod h1:LmEmu6L/8jetyj1oewewFb7bZCNRwE7wLCUNzDLaLVA=
2222
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d h1:r3mStZSyjKhEcgbJ5xtv7kT5PZw/tDiFBTMgQx2qsXE=
2323
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
24-
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
25-
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
2624
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
2725
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
26+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
27+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
28+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2829
github.com/google/go-jsonnet v0.17.0 h1:/9NIEfhK1NQRKl3sP2536b2+x5HnZMdql7x3yK/l8JY=
2930
github.com/google/go-jsonnet v0.17.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw=
3031
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ=
3132
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
3233
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
3334
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
34-
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
35-
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
3635
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
3736
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
3837
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -69,7 +68,6 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
6968
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
7069
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
7170
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
72-
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7371
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
7472
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
7573
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
@@ -78,15 +76,12 @@ golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8U
7876
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
7977
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
8078
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
81-
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
8279
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
8380
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
8481
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
8582
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
86-
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
8783
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
8884
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
89-
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
9085
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
9186
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
9287
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -106,16 +101,17 @@ golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiT
106101
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
107102
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
108103
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
109-
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
110104
golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
111-
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
112105
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
113106
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
114107
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
115108
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
116109
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
117110
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
118111
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
112+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
113+
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
114+
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
119115
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
120116
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
121117
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/backup_restore/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ and into this repository. This file isn't intended to be modified.
88

99
If `meta.pb.go` ever needs to be re-generated, follow these steps:
1010
1. Install `protoc` (i.e. via `brew install protobuf`)
11-
2. Run `go install github.com/gogo/protobuf/protoc-gen-gogo` from within this repository
11+
2. Run `go install google.golang.org/protobuf/cmd/protoc-gen-go` from within this repository
1212
3. Run `go generate <path to internal/backup_restore>`

internal/backup_restore/bolt.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"fmt"
77
"time"
88

9-
"github.com/gogo/protobuf/proto"
109
"github.com/influxdata/influx-cli/v2/api"
1110
"go.etcd.io/bbolt"
11+
"google.golang.org/protobuf/proto"
1212
)
1313

14-
//go:generate protoc --gogo_out=. meta.proto
14+
//go:generate protoc --go_out=. meta.proto
1515

1616
// NOTE: An unfortunate naming collision below. Bolt calls its databases "buckets".
1717
// These are the names that were used in the metadata DB for 2.0.x versions of influxdb.
@@ -62,7 +62,7 @@ func ExtractBucketMetadata(boltPath string) ([]api.BucketMetadataManifest, error
6262
// Read raw metadata needed to construct a manifest.
6363
var buckets []influxdbBucketSchema
6464
orgNamesById := map[string]string{}
65-
dbInfoByBucketId := map[string]DatabaseInfo{}
65+
dbInfoByBucketId := map[string]*DatabaseInfo{}
6666

6767
if err := db.View(func(tx *bbolt.Tx) error {
6868
bucketDB := tx.Bucket(bucketsBoltBucket)
@@ -113,7 +113,7 @@ func ExtractBucketMetadata(boltPath string) ([]api.BucketMetadataManifest, error
113113
return fmt.Errorf("failed to unmarshal v1 database info: %w", err)
114114
}
115115
for _, rawDBI := range pb.GetDatabases() {
116-
dbInfoByBucketId[*rawDBI.Name] = *rawDBI
116+
dbInfoByBucketId[*rawDBI.Name] = rawDBI
117117
}
118118

119119
return nil
@@ -137,7 +137,7 @@ func ExtractBucketMetadata(boltPath string) ([]api.BucketMetadataManifest, error
137137
return manifests, nil
138138
}
139139

140-
func combineMetadata(bucket influxdbBucketSchema, orgName string, dbi DatabaseInfo) api.BucketMetadataManifest {
140+
func combineMetadata(bucket influxdbBucketSchema, orgName string, dbi *DatabaseInfo) api.BucketMetadataManifest {
141141
m := api.BucketMetadataManifest{
142142
OrganizationID: bucket.OrgID,
143143
OrganizationName: orgName,
@@ -150,12 +150,12 @@ func combineMetadata(bucket influxdbBucketSchema, orgName string, dbi DatabaseIn
150150
m.Description = bucket.Description
151151
}
152152
for i, rp := range dbi.RetentionPolicies {
153-
m.RetentionPolicies[i] = convertRPI(*rp)
153+
m.RetentionPolicies[i] = convertRPI(rp)
154154
}
155155
return m
156156
}
157157

158-
func convertRPI(rpi RetentionPolicyInfo) api.RetentionPolicyManifest {
158+
func convertRPI(rpi *RetentionPolicyInfo) api.RetentionPolicyManifest {
159159
m := api.RetentionPolicyManifest{
160160
Name: *rpi.Name,
161161
ReplicaN: int32(*rpi.ReplicaN),
@@ -165,7 +165,7 @@ func convertRPI(rpi RetentionPolicyInfo) api.RetentionPolicyManifest {
165165
Subscriptions: make([]api.SubscriptionManifest, len(rpi.Subscriptions)),
166166
}
167167
for i, sg := range rpi.ShardGroups {
168-
m.ShardGroups[i] = convertSGI(*sg)
168+
m.ShardGroups[i] = convertSGI(sg)
169169
}
170170
for i, s := range rpi.Subscriptions {
171171
m.Subscriptions[i] = api.SubscriptionManifest{
@@ -177,7 +177,7 @@ func convertRPI(rpi RetentionPolicyInfo) api.RetentionPolicyManifest {
177177
return m
178178
}
179179

180-
func convertSGI(sgi ShardGroupInfo) api.ShardGroupManifest {
180+
func convertSGI(sgi *ShardGroupInfo) api.ShardGroupManifest {
181181
var deleted, truncated *time.Time
182182
if sgi.DeletedAt != nil {
183183
d := time.Unix(0, *sgi.DeletedAt).UTC()
@@ -197,12 +197,12 @@ func convertSGI(sgi ShardGroupInfo) api.ShardGroupManifest {
197197
Shards: make([]api.ShardManifest, len(sgi.Shards)),
198198
}
199199
for i, s := range sgi.Shards {
200-
m.Shards[i] = convertShard(*s)
200+
m.Shards[i] = convertShard(s)
201201
}
202202
return m
203203
}
204204

205-
func convertShard(shard ShardInfo) api.ShardManifest {
205+
func convertShard(shard *ShardInfo) api.ShardManifest {
206206
m := api.ShardManifest{
207207
Id: int64(*shard.ID),
208208
ShardOwners: make([]api.ShardOwner, len(shard.Owners)),

0 commit comments

Comments
 (0)