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