crowdsec/cmd/crowdsec-cli/flag.go
mmetc 9823ed61b6
cscli: log.Fatal -> return err (#3049)
* cscli: log.Fatal -> return err

* lint
2024-06-03 12:21:00 +02:00

29 lines
495 B
Go

package main
// Custom types for flag validation and conversion.
import (
"errors"
)
type MachinePassword string
func (p *MachinePassword) String() string {
return string(*p)
}
func (p *MachinePassword) Set(v string) error {
// a password can't be more than 72 characters
// due to bcrypt limitations
if len(v) > 72 {
return errors.New("password too long (max 72 characters)")
}
*p = MachinePassword(v)
return nil
}
func (p *MachinePassword) Type() string {
return "string"
}