mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-29 18:00:51 +01:00
refactor: Update models to use DatabaseV2 instead of DataSourceV2
This commit is contained in:
@@ -33,10 +33,10 @@ func GetMongoClient(opts ...ClientOption) (c *mongo.Client, err error) {
|
||||
_opts.Host = "localhost"
|
||||
}
|
||||
}
|
||||
if _opts.Port == "" {
|
||||
_opts.Port = viper.GetString("mongo.port")
|
||||
if _opts.Port == "" {
|
||||
_opts.Port = "27017"
|
||||
if _opts.Port == 0 {
|
||||
_opts.Port = viper.GetInt("mongo.port")
|
||||
if _opts.Port == 0 {
|
||||
_opts.Port = 27017
|
||||
}
|
||||
}
|
||||
if _opts.Db == "" {
|
||||
@@ -123,7 +123,7 @@ func newMongoClient(ctx context.Context, _opts *ClientOptions) (c *mongo.Client,
|
||||
mongoOpts.SetHosts(_opts.Hosts)
|
||||
} else {
|
||||
// hosts are unset
|
||||
mongoOpts.ApplyURI(fmt.Sprintf("mongodb://%s:%s/%s", _opts.Host, _opts.Port, _opts.Db))
|
||||
mongoOpts.ApplyURI(fmt.Sprintf("mongodb://%s:%d/%s", _opts.Host, _opts.Port, _opts.Db))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ type ClientOptions struct {
|
||||
Context context.Context
|
||||
Uri string
|
||||
Host string
|
||||
Port string
|
||||
Port int
|
||||
Db string
|
||||
Hosts []string
|
||||
Username string
|
||||
@@ -36,7 +36,7 @@ func WithHost(value string) ClientOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithPort(value string) ClientOption {
|
||||
func WithPort(value int) ClientOption {
|
||||
return func(options *ClientOptions) {
|
||||
options.Port = value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user