Пример #1
0
func (k *KeyData) Create() (ssh.KeyLocator, error) {
	handler, ok := ssh.KeyTypeHandlerFor(k.Type)
	if !ok {
		return nil, errors.New(fmt.Sprintf("The key type '%s' is not recognized.", k.Type))
	}
	return handler.CreateKey(k.Value)
}
Пример #2
0
func (k *KeyData) Check() error {
	_, ok := ssh.KeyTypeHandlerFor(k.Type)
	if !ok {
		return errors.New(fmt.Sprintf("The key type '%s' is not recognized.", k.Type))
	}
	if len(k.Value) == 0 {
		return errors.New("Value must be specified.")
	}
	return nil
}