mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
Fix issue with default port in bookmark; cleanup
This commit is contained in:
parent
d74bc06cbd
commit
59018287de
15
main.go
15
main.go
@ -30,8 +30,10 @@ func initClientUsingBookmark(bookmarkPath, bookmarkName string) (*client.Client,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opt := bookmark.ConvertToOptions()
|
||||
var connStr string
|
||||
|
||||
if opt.Url != "" { // if the bookmark has url set, use it
|
||||
connStr = opt.Url
|
||||
} else {
|
||||
@ -40,10 +42,12 @@ func initClientUsingBookmark(bookmarkPath, bookmarkName string) (*client.Client,
|
||||
return nil, fmt.Errorf("error building connection string: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
var ssh *shared.SSHInfo
|
||||
if !bookmark.SSHInfoIsEmpty() {
|
||||
ssh = &bookmark.Ssh
|
||||
}
|
||||
|
||||
return client.NewFromUrl(connStr, ssh)
|
||||
}
|
||||
|
||||
@ -54,16 +58,15 @@ func initClient() {
|
||||
|
||||
var cl *client.Client
|
||||
var err error
|
||||
|
||||
if options.Bookmark != "" {
|
||||
cl, err = initClientUsingBookmark(bookmarks.Path(), options.Bookmark)
|
||||
if err != nil {
|
||||
exitWithMessage(err.Error())
|
||||
}
|
||||
} else {
|
||||
cl, err = client.New()
|
||||
if err != nil {
|
||||
exitWithMessage(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
exitWithMessage(err.Error())
|
||||
}
|
||||
|
||||
if command.Opts.Debug {
|
||||
|
@ -95,10 +95,15 @@ func GetBookmark(bookmarkPath string, bookmarkName string) (Bookmark, error) {
|
||||
if err != nil {
|
||||
return Bookmark{}, err
|
||||
}
|
||||
|
||||
bookmark, ok := bookmarks[bookmarkName]
|
||||
if !ok {
|
||||
return Bookmark{}, fmt.Errorf("couldn't find a bookmark with name %s", bookmarkName)
|
||||
}
|
||||
return bookmark, nil
|
||||
|
||||
if bookmark.Port == 0 {
|
||||
bookmark.Port = 5432
|
||||
}
|
||||
|
||||
return bookmark, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user