Skip to content

Commit

Permalink
storage: add config options for UseFileRegistry and EncryptionOptions
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 14, 2021
1 parent fbdc57c commit 1dda7f6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
storage.Attributes(spec.Attributes),
storage.CacheSize(cfg.CacheSize),
storage.MaxSize(sizeInBytes),
storage.UseFileRegistry(spec.UseFileRegistry),
storage.EncryptionOptions(spec.EncryptionOptions),
storage.Settings(cfg.Settings))
if err != nil {
return Engines{}, err
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/sticky_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func (registry *stickyInMemEnginesRegistryImpl) GetOrCreateStickyInMemEngine(
storage.Attributes(spec.Attributes),
storage.CacheSize(cfg.CacheSize),
storage.MaxSize(spec.Size.InBytes),
storage.UseFileRegistry(spec.UseFileRegistry),
storage.EncryptionOptions(spec.EncryptionOptions),
storage.ForTesting)

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

// UseFileRegistry configures an engine to use the encryption-at-rest file
// registry. It is used to configure encryption-at-rest for in-memory engines,
// which are used in tests.
func UseFileRegistry(useRegistry bool) ConfigOption {
return func(cfg *engineConfig) error {
cfg.UseFileRegistry = useRegistry
return nil
}
}

// EncryptionOptions configures the encryption-at-rest options for an engine.
// It is used to configure encryption-at-rest for in-memory engines, which are
// used in tests.
func EncryptionOptions(b []byte) ConfigOption {
return func(cfg *engineConfig) error {
cfg.EncryptionOptions = make([]byte, len(b))
copy(cfg.EncryptionOptions, b)
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 1dda7f6

Please sign in to comment.