prysm-pulse/shared/cmd/password_reader.go
Connor Stein 4242581f1e
Test EnterPassword function in shared/cmd (#5822)
* test

* fix golint

* more lint

* gazelle

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
2020-05-12 10:01:02 -05:00

22 lines
474 B
Go

package cmd
import (
"golang.org/x/crypto/ssh/terminal"
"os"
)
// PasswordReader reads a password from a mock or stdin.
type PasswordReader interface {
ReadPassword() (string, error)
}
// StdInPasswordReader reads a password from stdin.
type StdInPasswordReader struct {
}
// ReadPassword reads a password from stdin.
func (pr StdInPasswordReader) ReadPassword() (string, error) {
pwd, error := terminal.ReadPassword(int(os.Stdin.Fd()))
return string(pwd), error
}