mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
refactor: Update models to use DatabaseV2 instead of DataSourceV2
This commit is contained in:
@@ -28,7 +28,7 @@ func getCockroachdbSession(ctx context.Context, ds *models.DataSource) (s db.Ses
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultCockroachdbPort
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func getCockroachdbSessionV2(ctx context.Context, ds *models2.DatabaseV2) (s db.
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultCockroachdbPort
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func getElasticsearchClient(ctx context.Context, ds *models.DataSource) (c *elas
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultElasticsearchPort
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func getElasticsearchClientV2(ctx context.Context, ds *models2.DatabaseV2) (c *e
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultElasticsearchPort
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ func getKafkaConnection(ctx context.Context, ds *models.DataSource) (c *kafka.Co
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultKafkaPort
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func getKafkaConnectionV2(ctx context.Context, ds *models2.DatabaseV2) (c *kafka
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultKafkaPort
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func getMongoClient(ctx context.Context, ds *models.DataSource) (c *mongo2.Clien
|
||||
if ds.Host == "" {
|
||||
ds.Host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
ds.Port = constants.DefaultMongoPort
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ func getMongoClient(ctx context.Context, ds *models.DataSource) (c *mongo2.Clien
|
||||
opts = append(opts, mongo.WithDb(ds.Database))
|
||||
opts = append(opts, mongo.WithUsername(ds.Username))
|
||||
opts = append(opts, mongo.WithPassword(ds.Password))
|
||||
opts = append(opts, mongo.WithHosts(ds.Hosts))
|
||||
|
||||
// extra
|
||||
if ds.Extra != nil {
|
||||
@@ -105,7 +104,7 @@ func getMongoClientV2(ctx context.Context, ds *models2.DatabaseV2) (c *mongo2.Cl
|
||||
if ds.Host == "" {
|
||||
ds.Host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
ds.Port = constants.DefaultMongoPort
|
||||
}
|
||||
|
||||
@@ -118,7 +117,6 @@ func getMongoClientV2(ctx context.Context, ds *models2.DatabaseV2) (c *mongo2.Cl
|
||||
opts = append(opts, mongo.WithDb(ds.Database))
|
||||
opts = append(opts, mongo.WithUsername(ds.Username))
|
||||
opts = append(opts, mongo.WithPassword(ds.Password))
|
||||
opts = append(opts, mongo.WithHosts(ds.Hosts))
|
||||
|
||||
// extra
|
||||
if ds.Extra != nil {
|
||||
|
||||
@@ -28,7 +28,7 @@ func getMssqlSession(ctx context.Context, ds *models.DataSource) (s db.Session,
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultMssqlPort
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func getMssqlSessionV2(ctx context.Context, ds *models2.DatabaseV2) (s db.Sessio
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultMssqlPort
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func getMysqlSession(ctx context.Context, ds *models.DataSource) (s db.Session,
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultMysqlPort
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func getMysqlSessionV2(ctx context.Context, ds *models2.DatabaseV2) (s db.Sessio
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultMysqlPort
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func getPostgresqlSession(ctx context.Context, ds *models.DataSource) (s db.Sess
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultPostgresqlPort
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func getPostgresqlSessionV2(ctx context.Context, ds *models2.DatabaseV2) (s db.S
|
||||
if ds.Host == "" {
|
||||
host = constants.DefaultHost
|
||||
}
|
||||
if ds.Port == "" {
|
||||
if ds.Port == 0 {
|
||||
port = constants.DefaultPostgresqlPort
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user