crowdsec/cmd/crowdsec-cli/flag.go

30 lines
543 B
Go
Raw Permalink Normal View History

2024-02-01 16:22:52 +00:00
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)")
}
2024-02-01 16:22:52 +00:00
*p = MachinePassword(v)
return nil
}
func (p *MachinePassword) Type() string {
return "string"
}