lncfg: make sure to only use native SQL with SQL backends

This commit is contained in:
Andras Banki-Horvath 2024-03-20 08:33:02 +01:00
parent b0552da007
commit 65c1f5483b
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8

View File

@ -122,13 +122,24 @@ func DefaultDB() *DB {
// Validate validates the DB config.
func (db *DB) Validate() error {
switch db.Backend {
case BoltBackend, SqliteBackend:
case BoltBackend:
if db.UseNativeSQL {
return fmt.Errorf("cannot use native SQL with bolt " +
"backend")
}
case SqliteBackend:
case PostgresBackend:
if err := db.Postgres.Validate(); err != nil {
return err
}
case EtcdBackend:
if db.UseNativeSQL {
return fmt.Errorf("cannot use native SQL with etcd " +
"backend")
}
if !db.Etcd.Embedded && db.Etcd.Host == "" {
return fmt.Errorf("etcd host must be set")
}