File tree Expand file tree Collapse file tree 4 files changed +23
-1
lines changed
vttablet/tabletserver/tabletenv Expand file tree Collapse file tree 4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,12 @@ func GetCredentialsServer() CredentialsServer {
133133 return cs
134134}
135135
136+ // SetDbCredentialsFilePath sets the value of the `--db-credentials-file` flag.
137+ // This should be used only for testing.
138+ func SetDbCredentialsFilePath (path string ) {
139+ dbCredentialsFile = path
140+ }
141+
136142// FileCredentialsServer is a simple implementation of CredentialsServer using
137143// a json file. Protected by mu.
138144type FileCredentialsServer struct {
Original file line number Diff line number Diff line change @@ -877,7 +877,12 @@ func (c *TabletConfig) verifyUnmanagedTabletConfig() error {
877877 return errors .New ("database app user not specified" )
878878 }
879879 if c .DB .App .Password == "" {
880- return errors .New ("database app user password not specified" )
880+ _ , pass , err := dbconfigs .GetCredentialsServer ().GetUserAndPassword (c .DB .App .User )
881+ if err == nil && pass != "" {
882+ c .DB .App .Password = pass
883+ } else {
884+ return errors .New ("database app user password not specified" )
885+ }
881886 }
882887 // Replication fixes should be disabled for Unmanaged tablets.
883888 mysqlctl .DisableActiveReparents = true
Original file line number Diff line number Diff line change @@ -484,4 +484,12 @@ func TestVerifyUnmanagedTabletConfig(t *testing.T) {
484484 config .DB .App .Password = "testPassword"
485485 err = config .verifyUnmanagedTabletConfig ()
486486 assert .Nil (t , err )
487+
488+ dbconfigs .SetDbCredentialsFilePath ("./data/db_credentials.json" )
489+ defer dbconfigs .SetDbCredentialsFilePath ("" )
490+ config .DB .App .Password = ""
491+
492+ err = config .verifyUnmanagedTabletConfig ()
493+ assert .Nil (t , err )
494+ assert .Equal (t , "testPassword" , config .DB .App .Password )
487495}
Original file line number Diff line number Diff line change 1+ {
2+ "testUser" : [" testPassword" ]
3+ }
You can’t perform that action at this time.
0 commit comments