Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2242)

Unified Diff: perf/go/perf_migratedb/main.go

Issue 813443002: Overhaul database package (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Assume the MySQL password is "" when running locally Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « perf/go/ingest/main.go ('k') | perf/go/skiaperf/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « perf/go/ingest/main.go ('k') | perf/go/skiaperf/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698