passwords not exported in MigrationContext
This commit is contained in:
parent
6f81d62a31
commit
4c6f42f2f1
@ -87,9 +87,9 @@ type MigrationContext struct {
|
||||
configMutex *sync.Mutex
|
||||
ConfigFile string
|
||||
CliUser string
|
||||
CliPassword string
|
||||
cliPassword string
|
||||
CliMasterUser string
|
||||
CliMasterPassword string
|
||||
cliMasterPassword string
|
||||
|
||||
HeartbeatIntervalMilliseconds int64
|
||||
defaultNumRetries int64
|
||||
@ -629,6 +629,18 @@ func (this *MigrationContext) AddThrottleControlReplicaKey(key mysql.InstanceKey
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *MigrationContext) SetCliPassword(password string) {
|
||||
this.cliPassword = password
|
||||
}
|
||||
|
||||
func (this *MigrationContext) SetCliMasterPassword(password string) {
|
||||
this.cliMasterPassword = password
|
||||
}
|
||||
|
||||
func (this *MigrationContext) GetCliMasterPassword() string {
|
||||
return this.cliMasterPassword
|
||||
}
|
||||
|
||||
// ApplyCredentials sorts out the credentials between the config file and the CLI flags
|
||||
func (this *MigrationContext) ApplyCredentials() {
|
||||
this.configMutex.Lock()
|
||||
@ -644,9 +656,9 @@ func (this *MigrationContext) ApplyCredentials() {
|
||||
if this.config.Client.Password != "" {
|
||||
this.InspectorConnectionConfig.Password = this.config.Client.Password
|
||||
}
|
||||
if this.CliPassword != "" {
|
||||
if this.cliPassword != "" {
|
||||
// Override
|
||||
this.InspectorConnectionConfig.Password = this.CliPassword
|
||||
this.InspectorConnectionConfig.Password = this.cliPassword
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ func main() {
|
||||
flag.StringVar(&migrationContext.AssumeMasterHostname, "assume-master-host", "", "(optional) explicitly tell gh-ost the identity of the master. Format: some.host.com[:port] This is useful in master-master setups where you wish to pick an explicit master, or in a tungsten-replicator where gh-ost is unabel to determine the master")
|
||||
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
|
||||
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
|
||||
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
|
||||
cliPassword := flag.String("password", "", "MySQL password")
|
||||
flag.StringVar(&migrationContext.CliMasterUser, "master-user", "", "MySQL user on master, if different from that on replica. Requires --assume-master-host")
|
||||
flag.StringVar(&migrationContext.CliMasterPassword, "master-password", "", "MySQL password on master, if different from that on replica. Requires --assume-master-host")
|
||||
cliMasterPassword := flag.String("master-password", "", "MySQL password on master, if different from that on replica. Requires --assume-master-host")
|
||||
flag.StringVar(&migrationContext.ConfigFile, "conf", "", "Config file")
|
||||
askPass := flag.Bool("ask-pass", false, "prompt for MySQL password")
|
||||
|
||||
@ -175,7 +175,7 @@ func main() {
|
||||
if migrationContext.CliMasterUser != "" && migrationContext.AssumeMasterHostname == "" {
|
||||
log.Fatalf("--master-user requires --assume-master-host")
|
||||
}
|
||||
if migrationContext.CliMasterPassword != "" && migrationContext.AssumeMasterHostname == "" {
|
||||
if *cliMasterPassword != "" && migrationContext.AssumeMasterHostname == "" {
|
||||
log.Fatalf("--master-password requires --assume-master-host")
|
||||
}
|
||||
|
||||
@ -202,13 +202,15 @@ func main() {
|
||||
if migrationContext.ServeSocketFile == "" {
|
||||
migrationContext.ServeSocketFile = fmt.Sprintf("/tmp/gh-ost.%s.%s.sock", migrationContext.DatabaseName, migrationContext.OriginalTableName)
|
||||
}
|
||||
migrationContext.SetCliPassword(*cliPassword)
|
||||
migrationContext.SetCliMasterPassword(*cliMasterPassword)
|
||||
if *askPass {
|
||||
fmt.Println("Password:")
|
||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
log.Fatale(err)
|
||||
}
|
||||
migrationContext.CliPassword = string(bytePassword)
|
||||
migrationContext.SetCliPassword(string(bytePassword))
|
||||
}
|
||||
migrationContext.SetHeartbeatIntervalMilliseconds(*heartbeatIntervalMillis)
|
||||
migrationContext.SetNiceRatio(*niceRatio)
|
||||
|
@ -663,8 +663,8 @@ func (this *Migrator) initiateInspector() (err error) {
|
||||
if this.migrationContext.CliMasterUser != "" {
|
||||
this.migrationContext.ApplierConnectionConfig.User = this.migrationContext.CliMasterUser
|
||||
}
|
||||
if this.migrationContext.CliMasterPassword != "" {
|
||||
this.migrationContext.ApplierConnectionConfig.Password = this.migrationContext.CliMasterPassword
|
||||
if this.migrationContext.GetCliMasterPassword() != "" {
|
||||
this.migrationContext.ApplierConnectionConfig.Password = this.migrationContext.GetCliMasterPassword()
|
||||
}
|
||||
log.Infof("Master forced to be %+v", *this.migrationContext.ApplierConnectionConfig.ImpliedKey)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user