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

Unified Diff: golden/go/correctness_migratedb/main.go

Issue 813443002: Overhaul database package (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Rebase 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
Index: golden/go/correctness_migratedb/main.go
diff --git a/golden/go/correctness_migratedb/main.go b/golden/go/correctness_migratedb/main.go
index 45ab64e4d240b48028d27ecd67170e06625efa7d..5c97ecb0e819b27d9af768fc3a8ba6a1cd6c7c3c 100644
--- a/golden/go/correctness_migratedb/main.go
+++ b/golden/go/correctness_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,34 +13,20 @@ import (
"skia.googlesource.com/buildbot.git/golden/go/db"
)
-func main() {
- defaultConnStr := db.GetConnectionString("root", "", "", "")
+var (
+ local = flag.Bool("local", false, "Running locally if true. As opposed to in production.")
+)
- // 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.")
+func main() {
+ // Set up flags.
+ database.SetupFlags(db.PROD_DB_HOST, db.PROD_DB_PORT, database.USER_ROOT, db.PROD_DB_NAME)
// Global init to initialize glog and parse arguments.
common.Init()
- var connectionStr = *dbConnString
-
- // 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"))
- }
-
- 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)

Powered by Google App Engine
This is Rietveld 408576698