提交 0530b3b9 编写于 作者: J Jeet Parekh

started work for source connection checking

上级 0390c220
......@@ -66,6 +66,8 @@ func runImport(args []string) error {
transformFile := flagset.String("transform_file", "", "transform file to use")
verify := flagset.Bool("verify", false, "verify the source and destination connections")
// use external config
config := flagset.String("config", "", "Path to external config file, if specified, only that is used")
......@@ -75,6 +77,10 @@ func runImport(args []string) error {
return err
}
if *verify {
return verifyConnections(*srcType, *srcURL, *ssl)
}
// use the config file
if *config != "" {
file, err := genPipelineFromEnv(*config)
......
// +build !oss
package main
import (
"database/sql"
_ "github.com/lib/pq"
)
func verifyConnections(srcType string, srcURL string, ssl bool) error {
switch srcType {
case "postgres":
if !ssl {
srcURL = srcURL + "?sslmode=disable"
}
conn, err := sql.Open("postgres", srcURL)
if err != nil {
return err
}
err = conn.Ping()
if err != nil {
return err
}
conn.Close()
default:
return nil
}
return nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册