MCPcopy Create free account
hub / github.com/cloudbase/garm / PromptPassword

Function PromptPassword

cmd/garm-cli/common/common.go:33–58  ·  view source on GitHub ↗
(label string, compareTo string)

Source from the content-addressed store, hash-verified

31)
32
33func PromptPassword(label string, compareTo string) (string, error) {
34 if label == "" {
35 label = "Password"
36 }
37 validate := func(input string) error {
38 passwordStenght := zxcvbn.PasswordStrength(input, nil)
39 if passwordStenght.Score < 4 {
40 return errors.New("password is too weak")
41 }
42 if compareTo != "" && compareTo != input {
43 return errors.New("passwords do not match")
44 }
45 return nil
46 }
47
48 prompt := promptui.Prompt{
49 Label: label,
50 Validate: validate,
51 Mask: '*',
52 }
53 result, err := prompt.Run()
54 if err != nil {
55 return "", err
56 }
57 return result, nil
58}
59
60func PromptString(label string, a ...interface{}) (string, error) {
61 validate := func(input string) error {

Callers 2

promptUnsetInitVariablesFunction · 0.92

Calls 1

RunMethod · 0.45

Tested by

no test coverage detected