build: upgrade protobuf library (#308)

This commit is contained in:
Dane Strandboge 2021-10-18 13:22:54 -05:00 committed by GitHub
parent 6fda4cceed
commit 3e76528ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 3486 additions and 2081 deletions

View File

@ -12,11 +12,11 @@ import (
"strings"
"time"
"github.com/gogo/protobuf/proto"
"github.com/influxdata/influx-cli/v2/api"
"github.com/influxdata/influx-cli/v2/clients"
br "github.com/influxdata/influx-cli/v2/internal/backup_restore"
"github.com/influxdata/influx-cli/v2/pkg/gzip"
"google.golang.org/protobuf/proto"
)
type ApiConfig interface {
@ -329,7 +329,7 @@ func (c Client) restoreBucketLegacy(ctx context.Context, bkt br.ManifestBucketEn
}
dbi := bucketToDBI(bkt)
dbiBytes, err := proto.Marshal(&dbi)
dbiBytes, err := proto.Marshal(dbi)
if err != nil {
return nil, err
}
@ -370,7 +370,7 @@ func (c Client) restoreOrg(ctx context.Context, name string) (string, error) {
return *orgs.GetOrgs()[0].Id, nil
}
func bucketToDBI(b br.ManifestBucketEntry) br.DatabaseInfo {
func bucketToDBI(b br.ManifestBucketEntry) *br.DatabaseInfo {
dbi := br.DatabaseInfo{
Name: &b.BucketID,
DefaultRetentionPolicy: &b.DefaultRetentionPolicy,
@ -379,12 +379,12 @@ func bucketToDBI(b br.ManifestBucketEntry) br.DatabaseInfo {
}
for i, rp := range b.RetentionPolicies {
converted := retentionPolicyToRPI(rp)
dbi.RetentionPolicies[i] = &converted
dbi.RetentionPolicies[i] = converted
}
return dbi
return &dbi
}
func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) br.RetentionPolicyInfo {
func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) *br.RetentionPolicyInfo {
replicaN := uint32(rp.ReplicaN)
rpi := br.RetentionPolicyInfo{
Name: &rp.Name,
@ -396,7 +396,7 @@ func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) br.RetentionPolicyInfo
}
for i, sg := range rp.ShardGroups {
converted := shardGroupToSGI(sg)
rpi.ShardGroups[i] = &converted
rpi.ShardGroups[i] = converted
}
for i, s := range rp.Subscriptions {
converted := br.SubscriptionInfo{
@ -406,10 +406,10 @@ func retentionPolicyToRPI(rp br.ManifestRetentionPolicy) br.RetentionPolicyInfo
}
rpi.Subscriptions[i] = &converted
}
return rpi
return &rpi
}
func shardGroupToSGI(sg br.ManifestShardGroup) br.ShardGroupInfo {
func shardGroupToSGI(sg br.ManifestShardGroup) *br.ShardGroupInfo {
id := uint64(sg.ID)
start := sg.StartTime.UnixNano()
end := sg.EndTime.UnixNano()
@ -430,12 +430,12 @@ func shardGroupToSGI(sg br.ManifestShardGroup) br.ShardGroupInfo {
}
for i, s := range sg.Shards {
converted := shardToSI(s)
sgi.Shards[i] = &converted
sgi.Shards[i] = converted
}
return sgi
return &sgi
}
func shardToSI(shard br.ManifestShardEntry) br.ShardInfo {
func shardToSI(shard br.ManifestShardEntry) *br.ShardInfo {
id := uint64(shard.ID)
si := br.ShardInfo{
ID: &id,
@ -446,7 +446,7 @@ func shardToSI(shard br.ManifestShardEntry) br.ShardInfo {
converted := br.ShardOwner{NodeID: &oid}
si.Owners[i] = &converted
}
return si
return &si
}
// readFileGzipped opens a local file and returns a reader of its contents,

2
go.mod
View File

@ -10,7 +10,6 @@ require (
github.com/fatih/color v1.9.0
github.com/fujiwara/shapeio v1.0.0
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.5.0
github.com/google/go-jsonnet v0.17.0
github.com/mattn/go-isatty v0.0.13
@ -20,6 +19,7 @@ require (
go.etcd.io/bbolt v1.3.6
golang.org/x/text v0.3.3
golang.org/x/tools v0.1.0
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
honnef.co/go/tools v0.2.0
)

16
go.sum
View File

@ -21,18 +21,17 @@ github.com/fujiwara/shapeio v1.0.0 h1:xG5D9oNqCSUUbryZ/jQV3cqe1v2suEjwPIcEg1gKM8
github.com/fujiwara/shapeio v1.0.0/go.mod h1:LmEmu6L/8jetyj1oewewFb7bZCNRwE7wLCUNzDLaLVA=
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d h1:r3mStZSyjKhEcgbJ5xtv7kT5PZw/tDiFBTMgQx2qsXE=
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-jsonnet v0.17.0 h1:/9NIEfhK1NQRKl3sP2536b2+x5HnZMdql7x3yK/l8JY=
github.com/google/go-jsonnet v0.17.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw=
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ=
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@ -69,7 +68,6 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
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
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -106,9 +101,7 @@ golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiT
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -116,6 +109,9 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -8,5 +8,5 @@ and into this repository. This file isn't intended to be modified.
If `meta.pb.go` ever needs to be re-generated, follow these steps:
1. Install `protoc` (i.e. via `brew install protobuf`)
2. Run `go install github.com/gogo/protobuf/protoc-gen-gogo` from within this repository
2. Run `go install google.golang.org/protobuf/cmd/protoc-gen-go` from within this repository
3. Run `go generate <path to internal/backup_restore>`

View File

@ -6,12 +6,12 @@ import (
"fmt"
"time"
"github.com/gogo/protobuf/proto"
"github.com/influxdata/influx-cli/v2/api"
"go.etcd.io/bbolt"
"google.golang.org/protobuf/proto"
)
//go:generate protoc --gogo_out=. meta.proto
//go:generate protoc --go_out=. meta.proto
// NOTE: An unfortunate naming collision below. Bolt calls its databases "buckets".
// 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
// Read raw metadata needed to construct a manifest.
var buckets []influxdbBucketSchema
orgNamesById := map[string]string{}
dbInfoByBucketId := map[string]DatabaseInfo{}
dbInfoByBucketId := map[string]*DatabaseInfo{}
if err := db.View(func(tx *bbolt.Tx) error {
bucketDB := tx.Bucket(bucketsBoltBucket)
@ -113,7 +113,7 @@ func ExtractBucketMetadata(boltPath string) ([]api.BucketMetadataManifest, error
return fmt.Errorf("failed to unmarshal v1 database info: %w", err)
}
for _, rawDBI := range pb.GetDatabases() {
dbInfoByBucketId[*rawDBI.Name] = *rawDBI
dbInfoByBucketId[*rawDBI.Name] = rawDBI
}
return nil
@ -137,7 +137,7 @@ func ExtractBucketMetadata(boltPath string) ([]api.BucketMetadataManifest, error
return manifests, nil
}
func combineMetadata(bucket influxdbBucketSchema, orgName string, dbi DatabaseInfo) api.BucketMetadataManifest {
func combineMetadata(bucket influxdbBucketSchema, orgName string, dbi *DatabaseInfo) api.BucketMetadataManifest {
m := api.BucketMetadataManifest{
OrganizationID: bucket.OrgID,
OrganizationName: orgName,
@ -150,12 +150,12 @@ func combineMetadata(bucket influxdbBucketSchema, orgName string, dbi DatabaseIn
m.Description = bucket.Description
}
for i, rp := range dbi.RetentionPolicies {
m.RetentionPolicies[i] = convertRPI(*rp)
m.RetentionPolicies[i] = convertRPI(rp)
}
return m
}
func convertRPI(rpi RetentionPolicyInfo) api.RetentionPolicyManifest {
func convertRPI(rpi *RetentionPolicyInfo) api.RetentionPolicyManifest {
m := api.RetentionPolicyManifest{
Name: *rpi.Name,
ReplicaN: int32(*rpi.ReplicaN),
@ -165,7 +165,7 @@ func convertRPI(rpi RetentionPolicyInfo) api.RetentionPolicyManifest {
Subscriptions: make([]api.SubscriptionManifest, len(rpi.Subscriptions)),
}
for i, sg := range rpi.ShardGroups {
m.ShardGroups[i] = convertSGI(*sg)
m.ShardGroups[i] = convertSGI(sg)
}
for i, s := range rpi.Subscriptions {
m.Subscriptions[i] = api.SubscriptionManifest{
@ -177,7 +177,7 @@ func convertRPI(rpi RetentionPolicyInfo) api.RetentionPolicyManifest {
return m
}
func convertSGI(sgi ShardGroupInfo) api.ShardGroupManifest {
func convertSGI(sgi *ShardGroupInfo) api.ShardGroupManifest {
var deleted, truncated *time.Time
if sgi.DeletedAt != nil {
d := time.Unix(0, *sgi.DeletedAt).UTC()
@ -197,12 +197,12 @@ func convertSGI(sgi ShardGroupInfo) api.ShardGroupManifest {
Shards: make([]api.ShardManifest, len(sgi.Shards)),
}
for i, s := range sgi.Shards {
m.Shards[i] = convertShard(*s)
m.Shards[i] = convertShard(s)
}
return m
}
func convertShard(shard ShardInfo) api.ShardManifest {
func convertShard(shard *ShardInfo) api.ShardManifest {
m := api.ShardManifest{
Id: int64(*shard.ID),
ShardOwners: make([]api.ShardOwner, len(shard.Owners)),

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,10 @@
// NOTE: This is a snapshot of the schema used to serialize V1 database info
// in the 2.0.x line of InfluxDB. The copy is here so we can support backing
// up from older DB versions, it's not intended to be kept up-to-date.
syntax = "proto2";
package internal;
option go_package = ".;backup_restore";
//========================================================================
//

View File

@ -12,8 +12,8 @@ package influxcli
import (
_ "github.com/daixiang0/gci"
_ "github.com/gogo/protobuf/protoc-gen-gogo"
_ "github.com/golang/mock/mockgen"
_ "golang.org/x/tools/cmd/goimports"
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
_ "honnef.co/go/tools/cmd/staticcheck"
)