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

Side by Side Diff: golden/go/db/db.go

Issue 650253003: Added HTTP endpoints for Correctness counts (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Addressed Comments Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 package db 1 package db
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 5
6 "github.com/golang/glog" 6 "github.com/golang/glog"
7 "skia.googlesource.com/buildbot.git/go/database" 7 "skia.googlesource.com/buildbot.git/go/database"
8 "skia.googlesource.com/buildbot.git/go/metadata" 8 "skia.googlesource.com/buildbot.git/go/metadata"
9 ) 9 )
10 10
11 const ( 11 const (
12 // Key of the password for the readwrite user. 12 // Key of the password for the readwrite user.
13 METADATA_KEY = "readwrite" 13 METADATA_KEY = "readwrite"
14 ) 14 )
15 15
16 // The migration steps for this DB. 16 // The migration steps for this DB.
17 func MigrationSteps() []database.MigrationStep { 17 func MigrationSteps() []database.MigrationStep {
18 return migrationSteps 18 return migrationSteps
19 } 19 }
20 20
21 // Returns the DB connection string for running in production where a 21 // Returns DatabaseConfig instance for running in production if a
22 // metadata server is available. If 'local' is true it will always return 22 // metadata server is available. If 'local' is true it will always
23 // "" (empty string). When used with Init() this will cause it to use a 23 // set the MySQL connection string to "" and thus use a local SQLite database
24 // local SQLite database. If it's not local and the meta data server is 24 // when used with database.NewVersionedDB.
25 // unreachable it will terminate. 25 func GetDatabaseConfig(mySQLConnStr string, sqlitePath string, local bool) *data base.DatabaseConfig {
26 func GetDatabase(mySQLConnStr string, sqlitePath string, local bool) *database.D atabaseConfig {
27 useMySQLConnStr := mySQLConnStr 26 useMySQLConnStr := mySQLConnStr
28 27
29 // We are in the production environment, so we look up the password. 28 // We are in the production environment, so we look up the password.
30 if !local { 29 if !local {
31 // First, get the password from the metadata server. 30 // First, get the password from the metadata server.
32 // See https://developers.google.com/compute/docs/metadata#custo m. 31 // See https://developers.google.com/compute/docs/metadata#custo m.
33 password, err := metadata.Get(METADATA_KEY) 32 password, err := metadata.Get(METADATA_KEY)
34 if err != nil { 33 if err != nil {
35 glog.Fatalf("Failed to find metadata. Use 'local' flag w hen running locally.") 34 glog.Fatalf("Failed to find metadata. Use 'local' flag w hen running locally.")
36 } 35 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 75
77 // Use this is a template for more migration steps. 76 // Use this is a template for more migration steps.
78 // version x 77 // version x
79 // { 78 // {
80 // MySQLUp: , 79 // MySQLUp: ,
81 // MySQLDown: , 80 // MySQLDown: ,
82 // SQLiteUp: , 81 // SQLiteUp: ,
83 // SQLiteDown: , 82 // SQLiteDown: ,
84 // }, 83 // },
85 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698