Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Options struct {
Host string `json:"host,omitempty"`
Port string `json:"port,omitempty"`
Password string `json:"password,omitempty"`
Database string `json:"database,omitempty"`
Filename string `json:"filename,omitempty"`
Engine string `json:"engine,omitempty"`
Logger logger.Handler
Expand Down Expand Up @@ -53,7 +54,14 @@ func New(opts Options) (Handler, error) {
switch opts.Engine {
case POSTGRES:
dsn := fmt.Sprintf("host=%s user=%s password=%s port=%s", opts.Host, opts.Username, opts.Password, opts.Port)
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if opts.Database != "" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please validate and improve error handling when Database is empty for Postgres.

Is meshery set as the default database name somewhere?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please validate and improve error handling when Database is empty for Postgres.

Is meshery set as the default database name somewhere?

No, "meshery" is not set as a default database name anywhere. The Postgres path in meshkit is currently unused by Meshery (which uses SQLite) .

dsn = fmt.Sprintf("%s dbname=%s", dsn, opts.Database)
}
config := &gorm.Config{}
if opts.Logger != nil {
config.Logger = opts.Logger.DatabaseLogger()
}
db, err := gorm.Open(postgres.Open(dsn), config)
if err != nil {
return Handler{}, ErrDatabaseOpen(err)
}
Expand Down
Loading