mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
6736b2867e
* feat: sql ssl connection * fix: simpler implementation of ssl-config in sql * fix(config): set db ssl connection by env vars
27 lines
556 B
Go
27 lines
556 B
Go
package repository
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/caos/zitadel/internal/config/types"
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/jinzhu/gorm"
|
|
)
|
|
|
|
type ViewConfig struct {
|
|
SQL *types.SQL
|
|
}
|
|
|
|
func Start(conf ViewConfig) (*sql.DB, *gorm.DB, error) {
|
|
sqlClient, err := conf.SQL.Start()
|
|
if err != nil {
|
|
return nil, nil, errors.ThrowPreconditionFailed(err, "SQL-9qBtr", "unable to open database connection")
|
|
}
|
|
|
|
client, err := gorm.Open("postgres", sqlClient)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
return sqlClient, client, nil
|
|
}
|