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
8 changed files with 3486 additions and 2081 deletions

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";
//========================================================================
//