Skip to content

Commit

Permalink
Add support for containers.conf database setting
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Heon <[email protected]>
  • Loading branch information
mheon committed Feb 22, 2023
1 parent 59a54f3 commit eb228f2
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions libpod/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,35 +334,36 @@ func makeRuntime(runtime *Runtime) (retErr error) {

// Set up the state.
//
// TODO: We probably need a "default" type that will select BoltDB if
// a DB exists already, and SQLite otherwise.
//
// TODO - if we further break out the state implementation into
// libpod/state, the config could take care of the code below. It
// would further allow to move the types and consts into a coherent
// package.
switch runtime.config.Engine.StateType {
case config.InMemoryStateStore:
return fmt.Errorf("in-memory state is currently disabled: %w", define.ErrInvalidArg)
case config.SQLiteStateStore:
return fmt.Errorf("SQLite state is currently disabled: %w", define.ErrInvalidArg)
case config.BoltDBStateStore:
if os.Getenv("PODMANDB") == "sqlite" {
state, err := NewSqliteState(runtime)
if err != nil {
return err
}
runtime.state = state
} else {
baseDir := runtime.config.Engine.StaticDir
if runtime.storageConfig.TransientStore {
baseDir = runtime.config.Engine.TmpDir
}
dbPath := filepath.Join(baseDir, "bolt_state.db")
backend, err := config.ParseDBBackend(runtime.config.Engine.DBBackend)
if err != nil {
return err
}
switch backend {
case config.DBBackendBoltDB:
baseDir := runtime.config.Engine.StaticDir
if runtime.storageConfig.TransientStore {
baseDir = runtime.config.Engine.TmpDir
}
dbPath := filepath.Join(baseDir, "bolt_state.db")

state, err := NewBoltState(dbPath, runtime)
if err != nil {
return err
}
runtime.state = state
state, err := NewBoltState(dbPath, runtime)
if err != nil {
return err
}
runtime.state = state
case config.DBBackendSQLite:
state, err := NewSqliteState(runtime)
if err != nil {
return err
}
runtime.state = state
default:
return fmt.Errorf("unrecognized state type passed (%v): %w", runtime.config.Engine.StateType, define.ErrInvalidArg)
}
Expand Down

0 comments on commit eb228f2

Please sign in to comment.