From 43b391c8d3c091c568634773b242698358a0a2db Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Thu, 23 May 2024 11:39:20 +0800 Subject: [PATCH] Bump etcd dependency --- cmd/decode_test.go | 3 ++- cmd/extract.go | 3 ++- go.mod | 4 ++-- go.sum | 10 ++++++---- pkg/data/data.go | 19 +++++++++++++------ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/cmd/decode_test.go b/cmd/decode_test.go index 9a15e42..683e3a9 100644 --- a/cmd/decode_test.go +++ b/cmd/decode_test.go @@ -24,8 +24,9 @@ import ( "strings" "testing" - "github.com/coreos/etcd/mvcc/mvccpb" "github.com/etcd-io/auger/pkg/encoding" + + "go.etcd.io/etcd/api/v3/mvccpb" ) var decodeTests = []struct { diff --git a/cmd/extract.go b/cmd/extract.go index 2103e83..9536e1c 100644 --- a/cmd/extract.go +++ b/cmd/extract.go @@ -24,12 +24,13 @@ import ( "strconv" "strings" - "github.com/coreos/etcd/mvcc/mvccpb" "github.com/etcd-io/auger/pkg/data" "github.com/etcd-io/auger/pkg/encoding" "github.com/etcd-io/auger/pkg/scheme" "github.com/google/safetext/yamltemplate" "github.com/spf13/cobra" + + "go.etcd.io/etcd/api/v3/mvccpb" ) var ( diff --git a/go.mod b/go.mod index eed8961..dd56fc3 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/etcd-io/auger go 1.22.0 require ( - github.com/coreos/bbolt v1.3.1-coreos.3 - github.com/coreos/etcd v3.1.11+incompatible github.com/google/safetext v0.0.0-20220914124124-e18e3fe012bf github.com/spf13/cobra v1.8.0 + go.etcd.io/bbolt v1.3.10 + go.etcd.io/etcd/api/v3 v3.5.13 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.30.1 k8s.io/apimachinery v0.30.1 diff --git a/go.sum b/go.sum index 7e1f4be..f72c832 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,3 @@ -github.com/coreos/bbolt v1.3.1-coreos.3 h1:sP70znHBV8469pbVsmR2G6wvd2oQwgxtgWyZvV3KVBo= -github.com/coreos/bbolt v1.3.1-coreos.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.1.11+incompatible h1:8Zwb+fsI+3wXGp23Pjn1eEFE/3P5ib5yXVoAMRxFOgM= -github.com/coreos/etcd v3.1.11+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -50,6 +46,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 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.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= +go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= +go.etcd.io/etcd/api/v3 v3.5.13 h1:8WXU2/NBge6AUF1K1gOexB6e07NgsN1hXK0rSTtgSp4= +go.etcd.io/etcd/api/v3 v3.5.13/go.mod h1:gBqlqkcMMZMVTMm4NDZloEVJzxQOQIls8splbqBDa0c= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -64,6 +64,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= 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/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/pkg/data/data.go b/pkg/data/data.go index e4f82fb..62f0312 100644 --- a/pkg/data/data.go +++ b/pkg/data/data.go @@ -26,11 +26,12 @@ import ( "strings" "text/template" - bolt "github.com/coreos/bbolt" - "github.com/coreos/etcd/mvcc/mvccpb" "github.com/etcd-io/auger/pkg/encoding" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" + + bolt "go.etcd.io/bbolt" + "go.etcd.io/etcd/api/v3/mvccpb" ) // See etcd/mvcc/kvstore.go:keyBucketName @@ -150,13 +151,19 @@ type Checksum struct { CompactRevision int64 } +func boltOpen(path string) (*bolt.DB, error) { + return bolt.Open(path, 0400, &bolt.Options{ + ReadOnly: true, + }) +} + // HashByRevision returns the checksum and revision. The checksum is of the live keyspace at a // particular revision. It is equivalent to performing a range request of all key-value pairs can // computing a hash of the data. If revision is 0, the latest revision is checksumed, else revision // is checksumed. The resulting hash is consistent particular revision in the presence of // compactions; so long as the revions itself has not been compacted, the hash never changes. func HashByRevision(filename string, revision int64) (Checksum, error) { - db, err := bolt.Open(filename, 0400, &bolt.Options{}) + db, err := boltOpen(filename) if err != nil { return Checksum{}, err } @@ -203,7 +210,7 @@ func getCompactRevision(db *bolt.DB) (int64, error) { // ListKeySummaries returns a result set with all the provided filters and projections applied. func ListKeySummaries(codecs serializer.CodecFactory, filename string, filters []Filter, proj *KeySummaryProjection, revision int64) ([]*KeySummary, error) { var err error - db, err := bolt.Open(filename, 0400, &bolt.Options{}) + db, err := boltOpen(filename) if err != nil { return nil, err } @@ -304,7 +311,7 @@ func sortKeySummaries(m map[string]*KeySummary) []*KeySummary { // ListVersions lists all versions of a object with the given key. func ListVersions(filename string, key string) ([]int64, error) { - db, err := bolt.Open(filename, 0400, &bolt.Options{}) + db, err := boltOpen(filename) if err != nil { return nil, err } @@ -327,7 +334,7 @@ func ListVersions(filename string, key string) ([]int64, error) { // GetValue scans the bucket of the bolt db file for a etcd v3 record with the given key and returns the value. // Because bolt db files are indexed by revision func GetValue(filename string, key string, version int64) ([]byte, error) { - db, err := bolt.Open(filename, 0400, &bolt.Options{}) + db, err := boltOpen(filename) if err != nil { return nil, err }