forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26477: cli: support encrypted stores in debug commands. r=mberhault a=mberhault Add the `--enterprise-encryption` flag to debug commands that open rocksdb. The flag is as specified in the start command. There are a few TODOs left: * support the ldb tool somehow * add tests for this, it'll need to be interactive tests in ccl/ Release note: None Co-authored-by: marc <[email protected]>
- Loading branch information
Showing
3 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2018 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package cliccl | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/ccl/baseccl" | ||
"github.com/cockroachdb/cockroach/pkg/ccl/cliccl/cliflagsccl" | ||
"github.com/cockroachdb/cockroach/pkg/cli" | ||
"github.com/cockroachdb/cockroach/pkg/storage/engine" | ||
) | ||
|
||
// This does not define new commands, only adds the encryption flag to debug commands in | ||
// `pkg/cli/debug.go` and registers a callback to generate encryption options. | ||
|
||
func init() { | ||
for _, cmd := range cli.DebugCmdsForRocksDB { | ||
// storeEncryptionSpecs is in start.go. | ||
cli.VarFlag(cmd.Flags(), &storeEncryptionSpecs, cliflagsccl.EnterpriseEncryption) | ||
} | ||
|
||
cli.PopulateRocksDBConfigHook = fillEncryptionOptionsForStore | ||
} | ||
|
||
// fillEncryptionOptionsForStore fills the RocksDBConfig fields | ||
// based on the --enterprise-encryption flag value. | ||
func fillEncryptionOptionsForStore(cfg *engine.RocksDBConfig) error { | ||
opts, err := baseccl.EncryptionOptionsForStore(cfg.Dir, storeEncryptionSpecs) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if opts != nil { | ||
cfg.ExtraOptions = opts | ||
cfg.UseFileRegistry = true | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters