github.com/crowdsecurity/crowdsec@v1.6.1/cmd/crowdsec-cli/flag.go (about) 1 package main 2 3 // Custom types for flag validation and conversion. 4 5 import ( 6 "errors" 7 ) 8 9 type MachinePassword string 10 11 func (p *MachinePassword) String() string { 12 return string(*p) 13 } 14 15 func (p *MachinePassword) Set(v string) error { 16 // a password can't be more than 72 characters 17 // due to bcrypt limitations 18 if len(v) > 72 { 19 return errors.New("password too long (max 72 characters)") 20 } 21 22 *p = MachinePassword(v) 23 24 return nil 25 } 26 27 func (p *MachinePassword) Type() string { 28 return "string" 29 }