Skip to content

Commit

Permalink
add option "-k" to debug tool for encryption support (#5113) (#5146)
Browse files Browse the repository at this point in the history
(cherry-picked from commit f38073a)
  • Loading branch information
parasssh committed Apr 9, 2020
1 parent 9a3dfc4 commit 6739627
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dgraph/cmd/debug/run.go
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/badger/v2/options"
"github.com/dgraph-io/dgraph/codec"
"github.com/dgraph-io/dgraph/ee/enc"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/protos/pb"
"github.com/dgraph-io/dgraph/types"
Expand All @@ -55,6 +56,7 @@ type flagOptions struct {
readTs uint64
sizeHistogram bool
noKeys bool
badgerKeyFile string

// Options related to the WAL.
wdir string
Expand Down Expand Up @@ -85,6 +87,8 @@ func init() {
flag.StringVarP(&opt.pdir, "postings", "p", "", "Directory where posting lists are stored.")
flag.BoolVar(&opt.sizeHistogram, "histogram", false,
"Show a histogram of the key and value sizes.")
flag.StringVarP(&opt.badgerKeyFile, "encryption_key_file", "k", "",
"File where the encryption key is stored.")

flag.StringVarP(&opt.wdir, "wal", "w", "", "Directory where Raft write-ahead logs are stored.")
flag.Uint64VarP(&opt.wtruncateUntil, "truncate", "t", 0,
Expand Down Expand Up @@ -763,7 +767,7 @@ func run() {
}
bopts := badger.DefaultOptions(dir).
WithTableLoadingMode(options.MemoryMap).
WithReadOnly(opt.readOnly)
WithReadOnly(opt.readOnly).WithEncryptionKey(enc.ReadEncryptionKeyFile(opt.badgerKeyFile))

// TODO(Ibrahim): Remove this once badger is updated.
bopts.ZSTDCompressionLevel = 1
Expand Down

0 comments on commit 6739627

Please sign in to comment.