zitadel/internal/view/repository/config.go
Silvan 6736b2867e
fix: Secure sql connection (#332)
* feat: sql ssl connection

* fix: simpler implementation of ssl-config in sql

* fix(config): set db ssl connection by env vars
2020-07-03 12:44:08 +02:00

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
}