Index: perf/go/perf_migratedb/main.go |
diff --git a/perf/go/perf_migratedb/main.go b/perf/go/perf_migratedb/main.go |
index 28021f775cded8709969db6f50607c7216bced02..22fc605541fcfafcb4d9ee61e298e67d43185ebb 100644 |
--- a/perf/go/perf_migratedb/main.go |
+++ b/perf/go/perf_migratedb/main.go |
@@ -5,11 +5,7 @@ package main |
// it is not entered via the command line. |
import ( |
- "bufio" |
"flag" |
- "fmt" |
- "os" |
- "strings" |
"github.com/golang/glog" |
"skia.googlesource.com/buildbot.git/go/common" |
@@ -17,32 +13,20 @@ import ( |
"skia.googlesource.com/buildbot.git/perf/go/db" |
) |
-func main() { |
- common.Init() |
- defaultConnStr := strings.Replace(db.DB_CONN_TMPL, "%s", "root", 1) |
- |
- // flags |
- dbConnString := flag.String("db_conn_string", defaultConnStr, "\n\tDatabase string to open connect to the MySQL database. "+ |
- "\n\tNeeds to follow the format of the golang-mysql driver (https://github.com/go-sql-driver/mysql."+ |
- "\n\tIf the string contains %s the user will be prompted to enter a password which will then be used for subtitution.") |
+var ( |
+ local = flag.Bool("local", false, "Running locally if true. As opposed to in production.") |
+) |
- var connectionStr = *dbConnString |
+func main() { |
+ // Set up flags. |
+ database.SetupFlags(db.PROD_DB_HOST, db.PROD_DB_PORT, database.USER_ROOT, db.PROD_DB_NAME) |
- // if it contains formatting information read the password from stdin. |
- if strings.Contains(connectionStr, "%s") { |
- glog.Infof("Using connection string: %s", connectionStr) |
- reader := bufio.NewReader(os.Stdin) |
- fmt.Print("Enter password for MySQL: ") |
- password, err := reader.ReadString('\n') |
- if err != nil { |
- glog.Fatalf("Unable to read password. Error: %s", err) |
- } |
- connectionStr = fmt.Sprintf(connectionStr, strings.TrimRight(password, "\n")) |
- } |
+ // Global init to initialize glog and parse arguments. |
+ common.Init() |
- conf := &database.DatabaseConfig{ |
- MySQLString: connectionStr, |
- MigrationSteps: db.MigrationSteps(), |
+ conf, err := database.ConfigFromFlagsAndMetadata(*local, db.MigrationSteps()) |
+ if err != nil { |
+ glog.Fatal(err) |
} |
vdb := database.NewVersionedDB(conf) |