prysm-pulse/cmd/password_reader.go
Manu NALEPA 99a8d0bac6
Validator client - Improve readability - NO FUNCTIONAL CHANGE (#13468)
* Improve `NewServiceRegistry` documentation.

* Improve `README.md`.

* Improve readability of `registerValidatorService`.

* Move `log` in `main.go`.

Since `log` is only used in `main.go`.

* Clean Tos.

* `DefaultDataDir`: Use `switch` instead of `if/elif`.

* `ReadPassword`: Remove unused receiver.

* `validator/main.go`: Clean.

* `WarnIfPlatformNotSupported`: Add Mac OSX ARM64.

* `runner.go`: Use idiomatic `err` handling.

* `waitForChainStart`: Avoid `chainStartResponse`mutation.

* `WaitForChainStart`: Reduce cognitive complexity.

* Logs: `powchain` ==> `execution`.
2024-01-15 14:46:54 +00:00

23 lines
468 B
Go

package cmd
import (
"os"
"golang.org/x/crypto/ssh/terminal"
)
// 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 (StdInPasswordReader) ReadPassword() (string, error) {
pwd, err := terminal.ReadPassword(int(os.Stdin.Fd()))
return string(pwd), err
}