Skip to content

Commit 35ace62

Browse files
author
Shlomi Noach
authored
Merge pull request #334 from github/ask-pass
supporting --ask-pass option
2 parents 322d897 + aa0932e commit 35ace62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+17122
-0
lines changed

go/cmd/gh-ost/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/github/gh-ost/go/base"
1616
"github.com/github/gh-ost/go/logic"
1717
"github.com/outbrain/golib/log"
18+
19+
"golang.org/x/crypto/ssh/terminal"
1820
)
1921

2022
var AppVersion string
@@ -49,6 +51,7 @@ func main() {
4951
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
5052
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
5153
flag.StringVar(&migrationContext.ConfigFile, "conf", "", "Config file")
54+
askPass := flag.Bool("ask-pass", false, "prompt for MySQL password")
5255

5356
flag.StringVar(&migrationContext.DatabaseName, "database", "", "database name (mandatory)")
5457
flag.StringVar(&migrationContext.OriginalTableName, "table", "", "table name (mandatory)")
@@ -194,6 +197,14 @@ func main() {
194197
if migrationContext.ServeSocketFile == "" {
195198
migrationContext.ServeSocketFile = fmt.Sprintf("/tmp/gh-ost.%s.%s.sock", migrationContext.DatabaseName, migrationContext.OriginalTableName)
196199
}
200+
if *askPass {
201+
fmt.Println("Password:")
202+
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
203+
if err != nil {
204+
log.Fatale(err)
205+
}
206+
migrationContext.CliPassword = string(bytePassword)
207+
}
197208
migrationContext.SetHeartbeatIntervalMilliseconds(*heartbeatIntervalMillis)
198209
migrationContext.SetNiceRatio(*niceRatio)
199210
migrationContext.SetChunkSize(*chunkSize)

0 commit comments

Comments
 (0)