Skip to content

Commit e1f0c01

Browse files
authored
feat(backend): add postgres initialization (#9798)
* add postgres initialization * remove load balancer * go mod tidy * update license * license update for viewer * (test) disable controller license check * (test) disable persistence agence licence check * (test) disable scheduled workflow license check * (test) disable cacheserver license check * fix db config location * fix mysql support * test * test * no long set host address * address comments * address comments and enable license check * format * remove extra blank line * update licenses * cache server license * address comments * centralize error message * remove pv in postgres deployment
1 parent b350ac4 commit e1f0c01

File tree

20 files changed

+428
-151
lines changed

20 files changed

+428
-151
lines changed

backend/src/apiserver/client/sql.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515
package client
1616

1717
import (
18+
"bytes"
1819
"fmt"
1920

2021
"github.com/go-sql-driver/mysql"
2122
)
2223

23-
func CreateMySQLConfig(user, password string, mysqlServiceHost string,
24-
mysqlServicePort string, dbName string, mysqlGroupConcatMaxLen string, mysqlExtraParams map[string]string,
24+
const (
25+
MYSQL_TEXT_FORMAT string = "longtext not null"
26+
MYSQL_EXIST_ERROR string = "database exists"
27+
28+
PGX_TEXT_FORMAT string = "text"
29+
PGX_EXIST_ERROR string = "already exists"
30+
)
31+
32+
func CreateMySQLConfig(user, password, mysqlServiceHost, mysqlServicePort,
33+
dbName, mysqlGroupConcatMaxLen string, mysqlExtraParams map[string]string,
2534
) *mysql.Config {
2635
params := map[string]string{
2736
"charset": "utf8",
@@ -44,3 +53,26 @@ func CreateMySQLConfig(user, password string, mysqlServiceHost string,
4453
AllowNativePasswords: true,
4554
}
4655
}
56+
57+
func CreatePostgreSQLConfig(user, password, postgresHost, dbName string, postgresPort uint16,
58+
) string {
59+
var b bytes.Buffer
60+
if dbName != "" {
61+
fmt.Fprintf(&b, "database=%s ", dbName)
62+
}
63+
if user != "" {
64+
fmt.Fprintf(&b, "user=%s ", user)
65+
}
66+
if password != "" {
67+
fmt.Fprintf(&b, "password=%s ", password)
68+
}
69+
if postgresHost != "" {
70+
fmt.Fprintf(&b, "host=%s ", postgresHost)
71+
}
72+
if postgresPort != 0 {
73+
fmt.Fprintf(&b, "port=%d ", postgresPort)
74+
}
75+
fmt.Fprint(&b, "sslmode=disable")
76+
77+
return b.String()
78+
}

0 commit comments

Comments
 (0)