vendor latest c/common

Includes the default db backend changes.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-10-10 14:24:24 +02:00
parent 040a4e4b1e
commit 8a52e638e6
31 changed files with 953 additions and 192 deletions

View File

@@ -13,6 +13,12 @@ const (
// SQLite backend.
DBBackendSQLite
// DBBackendDefault describes that no explicit backend has been set.
// It should default to sqlite unless there is already an existing boltdb,
// this allows for backwards compatibility on upgrades. The actual detection
// logic must live in podman as we only know there were to look for the file.
DBBackendDefault
stringBoltDB = "boltdb"
stringSQLite = "sqlite"
)
@@ -24,6 +30,8 @@ func (d DBBackend) String() string {
return stringBoltDB
case DBBackendSQLite:
return stringSQLite
case DBBackendDefault:
return ""
default:
return fmt.Sprintf("unsupported database backend: %d", d)
}
@@ -32,7 +40,7 @@ func (d DBBackend) String() string {
// Validate returns whether the DBBackend is supported.
func (d DBBackend) Validate() error {
switch d {
case DBBackendBoltDB, DBBackendSQLite:
case DBBackendBoltDB, DBBackendSQLite, DBBackendDefault:
return nil
default:
return fmt.Errorf("unsupported database backend: %d", d)
@@ -49,12 +57,9 @@ func ParseDBBackend(raw string) (DBBackend, error) {
return DBBackendBoltDB, nil
case stringSQLite:
return DBBackendSQLite, nil
case "":
return DBBackendDefault, nil
default:
return DBBackendUnsupported, fmt.Errorf("unsupported database backend: %q", raw)
}
}
// DBBackend returns the configured database backend.
func (c *Config) DBBackend() (DBBackend, error) {
return ParseDBBackend(c.Engine.DBBackend)
}