File tree Expand file tree Collapse file tree 1 file changed +4
-19
lines changed Expand file tree Collapse file tree 1 file changed +4
-19
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package db
2
2
3
3
import (
4
4
"fmt"
5
+ "github.com/gravitl/netmaker/servercfg"
5
6
"os"
6
7
"strconv"
7
8
@@ -18,7 +19,7 @@ type postgresConnector struct{}
18
19
// postgresConnector.connect connects and
19
20
// initializes a connection to postgres.
20
21
func (pg * postgresConnector ) connect () (* gorm.DB , error ) {
21
- pgConf := GetSQLConf ()
22
+ pgConf := servercfg . GetSQLConf ()
22
23
dsn := fmt .Sprintf (
23
24
"host=%s port=%d user=%s password=%s dbname=%s sslmode=%s connect_timeout=5" ,
24
25
pgConf .Host ,
@@ -29,27 +30,11 @@ func (pg *postgresConnector) connect() (*gorm.DB, error) {
29
30
pgConf .SSLMode ,
30
31
)
31
32
32
- db , err := gorm .Open (postgres .Open (dsn ), & gorm.Config {
33
+ return gorm .Open (postgres .Open (dsn ), & gorm.Config {
33
34
Logger : logger .Default .LogMode (logger .Silent ),
34
35
})
35
- if err != nil {
36
- return nil , err
37
- }
38
-
39
- // ensure netmaker_v1 schema exists.
40
- err = db .Exec ("CREATE SCHEMA IF NOT EXISTS netmaker_v1" ).Error
41
- if err != nil {
42
- return nil , err
43
- }
44
-
45
- // set the netmaker_v1 schema as the default schema.
46
- err = db .Exec ("SET search_path TO netmaker_v1" ).Error
47
- if err != nil {
48
- return nil , err
49
- }
50
-
51
- return db , nil
52
36
}
37
+
53
38
func GetSQLConf () config.SQLConfig {
54
39
var cfg config.SQLConfig
55
40
cfg .Host = GetSQLHost ()
You can’t perform that action at this time.
0 commit comments