Remove defaultKeyPair type. Be more specific in errors.

This commit is contained in:
Stephen Fox 2019-02-07 11:09:53 -05:00
parent 08eb4615d4
commit ed1d224b97
2 changed files with 2 additions and 30 deletions

View File

@ -1,28 +0,0 @@
package ssh
type defaultKeyPair struct {
}
func (o defaultKeyPair) Type() KeyPairType {
return Default
}
func (o defaultKeyPair) Bits() int {
return 0
}
func (o defaultKeyPair) Name() string {
return ""
}
func (o defaultKeyPair) Description() string {
return ""
}
func (o defaultKeyPair) PrivateKeyPemBlock() []byte {
return []byte{}
}
func (o defaultKeyPair) PublicKeyAuthorizedKeysLine(nl NewLineOption) []byte {
return []byte{}
}

View File

@ -139,7 +139,7 @@ func (o *defaultKeyPairBuilder) Build() (KeyPair, error) {
return o.newEcdsaKeyPair()
}
return defaultKeyPair{}, fmt.Errorf("Unsupported keypair type: %s", o.kind.String())
return nil, fmt.Errorf("Cannot generate SSH key pair - unsupported key pair type: %s", o.kind.String())
}
// preallocatedKeyPair returns an SSH key pair based on user
@ -197,7 +197,7 @@ func (o *defaultKeyPairBuilder) preallocatedKeyPair() (KeyPair, error) {
}, nil
}
return &defaultKeyPair{}, fmt.Errorf("Unknown ssh key pair type")
return nil, fmt.Errorf("Cannot parse preallocated key pair - unknown ssh key pair type")
}
// newEcdsaKeyPair returns a new ECDSA SSH key pair.