MCPcopy Create free account
hub / github.com/cloudbase/garm / GormParams

Method GormParams

config/config.go:496–516  ·  view source on GitHub ↗

GormParams returns the database type and connection URI

()

Source from the content-addressed store, hash-verified

494
495// GormParams returns the database type and connection URI
496func (d *Database) GormParams() (dbType DBBackendType, uri string, err error) {
497 if err := d.Validate(); err != nil {
498 return "", "", fmt.Errorf("error validating database config: %w", err)
499 }
500 dbType = d.DbBackend
501 switch dbType {
502 case MySQLBackend:
503 uri, err = d.MySQL.ConnectionString()
504 if err != nil {
505 return "", "", fmt.Errorf("error fetching mysql connection string: %w", err)
506 }
507 case SQLiteBackend:
508 uri, err = d.SQLite.ConnectionString()
509 if err != nil {
510 return "", "", fmt.Errorf("error fetching sqlite3 connection string: %w", err)
511 }
512 default:
513 return "", "", fmt.Errorf("invalid database backend: %s", dbType)
514 }
515 return
516}
517
518func (d *Database) SQLiteBlobDatabaseConfig() (Database, error) {
519 if d.DbBackend != SQLiteBackend {

Callers 2

newDBConnFunction · 0.80
TestGormParamsFunction · 0.80

Calls 2

ValidateMethod · 0.95
ConnectionStringMethod · 0.45

Tested by 1

TestGormParamsFunction · 0.64