Skip to content

Commit

Permalink
storage: add config option for enabling encryption-at-rest
Browse files Browse the repository at this point in the history
This patch adds the ability to configure encryption-at-rest for
in-memory engines, which are used in tests.

Release note: None
  • Loading branch information
Andy Yang committed Aug 16, 2021
1 parent fbdc57c commit 506a61c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
storage.Attributes(spec.Attributes),
storage.CacheSize(cfg.CacheSize),
storage.MaxSize(sizeInBytes),
storage.EncryptionAtRest(spec.EncryptionOptions),
storage.Settings(cfg.Settings))
if err != nil {
return Engines{}, err
Expand Down
1 change: 1 addition & 0 deletions pkg/server/sticky_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (registry *stickyInMemEnginesRegistryImpl) GetOrCreateStickyInMemEngine(
storage.Attributes(spec.Attributes),
storage.CacheSize(cfg.CacheSize),
storage.MaxSize(spec.Size.InBytes),
storage.EncryptionAtRest(spec.EncryptionOptions),
storage.ForTesting)

engineEntry := &stickyInMemEngine{
Expand Down
13 changes: 13 additions & 0 deletions pkg/storage/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ func CacheSize(size int64) ConfigOption {
}
}

// EncryptionAtRest configures an engine to use encryption-at-rest. It is used
// for configuring in-memory engines, which are used in tests. It is not safe
// to modify the given slice afterwards as it is captured by reference.
func EncryptionAtRest(encryptionOptions []byte) ConfigOption {
return func(cfg *engineConfig) error {
if len(encryptionOptions) > 0 {
cfg.UseFileRegistry = true
cfg.EncryptionOptions = encryptionOptions
}
return nil
}
}

// Hook configures a hook to initialize additional storage options. It's used
// to initialize encryption-at-rest details in CCL builds.
func Hook(hookFunc func(*base.StorageConfig) error) ConfigOption {
Expand Down

0 comments on commit 506a61c

Please sign in to comment.