mirror of
https://github.com/mayflower/docker-ls.git
synced 2026-10-24 13:39:17 +03:00
28 lines
483 B
Go
28 lines
483 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"syscall"
|
|
|
|
"golang.org/x/crypto/ssh/terminal"
|
|
|
|
"github.com/mayflower/docker-ls/lib"
|
|
)
|
|
|
|
func PromptPassword(config *lib.Config) (err error) {
|
|
credentials := config.Credentials()
|
|
|
|
fmt.Fprintf(os.Stderr, "please enter password for user %s: ", credentials.User())
|
|
|
|
binaryPassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
credentials.SetPassword(string(binaryPassword))
|
|
fmt.Fprintln(os.Stderr)
|
|
|
|
return
|
|
}
|