multi: switch from bolt packge to bbolt package for all imports

This commit is contained in:
Olaoluwa Osuntokun committed 2018-11-29 20:33:49 -08:00
1 parent 0edf1ae081
commit 1fd3aac925
41 files changed
+404 -405

No files matched your search

+3 -4
View File
@@ -6,6 +6,7 @@ import (
"os"
"path"
"github.com/coreos/bbolt"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
@@ -14,8 +15,6 @@ import (
macaroon "gopkg.in/macaroon.v2"
"golang.org/x/net/context"
"github.com/coreos/bbolt"
)
var (
@@ -50,8 +49,8 @@ func NewService(dir string, checks ...Checker) (*Service, error) {
// Open the database that we'll use to store the primary macaroon key,
// and all generated macaroons+caveats.
macaroonDB, err := bolt.Open(
path.Join(dir, DBFilename), 0600, bolt.DefaultOptions,
macaroonDB, err := bbolt.Open(
path.Join(dir, DBFilename), 0600, bbolt.DefaultOptions,
)
if err != nil {
return nil, err
+2 -2
View File
@@ -33,8 +33,8 @@ func setupTestRootKeyStorage(t *testing.T) string {
if err != nil {
t.Fatalf("Error creating temp dir: %v", err)
}
db, err := bolt.Open(path.Join(tempDir, "macaroons.db"), 0600,
bolt.DefaultOptions)
db, err := bbolt.Open(path.Join(tempDir, "macaroons.db"), 0600,
bbolt.DefaultOptions)
if err != nil {
t.Fatalf("Error opening store DB: %v", err)
}
+6 -6
View File
@@ -46,16 +46,16 @@ var (
// RootKeyStorage implements the bakery.RootKeyStorage interface.
type RootKeyStorage struct {
*bolt.DB
*bbolt.DB
encKey *snacl.SecretKey
}
// NewRootKeyStorage creates a RootKeyStorage instance.
// TODO(aakselrod): Add support for encryption of data with passphrase.
func NewRootKeyStorage(db *bolt.DB) (*RootKeyStorage, error) {
func NewRootKeyStorage(db *bbolt.DB) (*RootKeyStorage, error) {
// If the store's bucket doesn't exist, create it.
err := db.Update(func(tx *bolt.Tx) error {
err := db.Update(func(tx *bbolt.Tx) error {
_, err := tx.CreateBucketIfNotExists(rootKeyBucketName)
return err
})
@@ -80,7 +80,7 @@ func (r *RootKeyStorage) CreateUnlock(password *[]byte) error {
return ErrPasswordRequired
}
return r.Update(func(tx *bolt.Tx) error {
return r.Update(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(rootKeyBucketName)
dbKey := bucket.Get(encryptedKeyID)
if len(dbKey) > 0 {
@@ -124,7 +124,7 @@ func (r *RootKeyStorage) Get(_ context.Context, id []byte) ([]byte, error) {
return nil, ErrStoreLocked
}
var rootKey []byte
err := r.View(func(tx *bolt.Tx) error {
err := r.View(func(tx *bbolt.Tx) error {
dbKey := tx.Bucket(rootKeyBucketName).Get(id)
if len(dbKey) == 0 {
return fmt.Errorf("root key with id %s doesn't exist",
@@ -156,7 +156,7 @@ func (r *RootKeyStorage) RootKey(_ context.Context) ([]byte, []byte, error) {
}
var rootKey []byte
id := defaultRootKeyID
err := r.Update(func(tx *bolt.Tx) error {
err := r.Update(func(tx *bbolt.Tx) error {
ns := tx.Bucket(rootKeyBucketName)
dbKey := ns.Get(id)
+4 -4
View File
@@ -21,8 +21,8 @@ func TestStore(t *testing.T) {
}
defer os.RemoveAll(tempDir)
db, err := bolt.Open(path.Join(tempDir, "weks.db"), 0600,
bolt.DefaultOptions)
db, err := bbolt.Open(path.Join(tempDir, "weks.db"), 0600,
bbolt.DefaultOptions)
if err != nil {
t.Fatalf("Error opening store DB: %v", err)
}
@@ -75,8 +75,8 @@ func TestStore(t *testing.T) {
// Between here and the re-opening of the store, it's possible to get
// a double-close, but that's not such a big deal since the tests will
// fail anyway in that case.
db, err = bolt.Open(path.Join(tempDir, "weks.db"), 0600,
bolt.DefaultOptions)
db, err = bbolt.Open(path.Join(tempDir, "weks.db"), 0600,
bbolt.DefaultOptions)
if err != nil {
t.Fatalf("Error opening store DB: %v", err)
}