Documentation ¶
Index ¶
- Variables
- func BaseJoin(base string, paths ...string) string
- func CheckAccountName(s string) bool
- func CheckHostID(s string) bool
- func CheckSSHAgent()
- func CheckUserID(s string) bool
- func ColorFunc(attr ...color.Attribute) func(string) string
- func CreateRSAPrivateKey(bits int) (privateKey *rsa.PrivateKey, err error)
- func EncodePrivateKey(privateKey *rsa.PrivateKey) ([]byte, error)
- func EncodePublicKey(publicKey interface{}) (b []byte, err error)
- func FindSignerInSSHAgentFromFile(file string) (signer saultssh.Signer, err error)
- func FindSignerInSSHAgentFromPublicKey(publicKey saultssh.PublicKey) (signer saultssh.Signer, err error)
- func FingerprintMD5PublicKey(key saultssh.PublicKey) string
- func FingerprintSHA256PublicKey(key saultssh.PublicKey) string
- func GetAuthorizedKey(publicKey saultssh.PublicKey) string
- func GetDefaultLogrusFormatter() logrus.Formatter
- func GetSSHAgent() (saultsshAgent.Agent, error)
- func GetServerLogrusFormatter() logrus.Formatter
- func GetSignerFromPrivateKey(s []byte) (saultssh.Signer, error)
- func LoadPrivateKeySignerWithPasspharaseTrial(privateKeyFile string) (signer saultssh.Signer, err error)
- func LoadPublicKeyFromPrivateKeyFile(f string) (publicKey saultssh.PublicKey, err error)
- func MakeFirstLowerCase(s string) string
- func MakeFirstUpperCase(s string) string
- func MakeOutputString(log *logrus.Logger, s string, level logrus.Level) string
- func MakePascalCase(s string) string
- func MakeRandomString() string
- func MakeUUID() string
- func ParseBooleanString(s string) (v bool, err error)
- func ParseHostAccount(s string) (userName, hostName string, err error)
- func ParseMinusName(s string) (name string, minus bool)
- func ParsePublicKey(b []byte) (saultssh.PublicKey, error)
- func ParseSaultAccountName(s string) (account, hostID string, err error)
- func PrintInstance(data interface{})
- func PrintfInstance(format string, data ...interface{})
- func ReadPassword(maxTries int) (password string, err error)
- func SetupLog(level logrus.Level, out io.Writer, formatter logrus.Formatter)
- func SimpleTemplating(t string, values interface{}) (string, error)
- func SplitHostPort(s string, defaultPort uint64) (host string, port uint64, err error)
- func SprintInstance(data interface{}) string
- func SprintfInstance(format string, data ...interface{}) string
- func StringFilter(vs []string, f func(string) bool) []string
- func Templating(t, name string, values interface{}) (string, error)
- type CommandError
- type CommandErrorType
- type CommandMsg
- type DefaultLogrusFormatter
- type FlagPrivateKey
- type FlagSaultServer
- type HostAndUserNotLinked
- type HostDoesNotExistError
- type HostExistError
- type HostNothingToUpdate
- type InvalidAccountNameError
- type InvalidHostAddressError
- type InvalidHostIDError
- type InvalidUserIDError
- type LinkedAllError
- type ResponseMsg
- type ResponseMsgError
- type SSHAgentNotRunning
- type SSHClient
- func (s *SSHClient) AddAuthMethod(auths ...saultssh.AuthMethod)
- func (s *SSHClient) Close()
- func (s *SSHClient) Connect() error
- func (s *SSHClient) GetFile(dest string) (content []byte, err error)
- func (s *SSHClient) MakeDir(dest string, perm os.FileMode, recursive bool) error
- func (s *SSHClient) PutFile(content string, dest string, perm os.FileMode) error
- func (s *SSHClient) Remove(dest string) error
- func (s *SSHClient) Run(cmd string) (output []byte, err error)
- func (s *SSHClient) SetTimeout(t time.Duration)
- type TermSize
- type UserDoesNotExistError
- type UserExistsError
- type UserNothingToUpdate
Constants ¶
This section is empty.
Variables ¶
var DefaultTOML toml.Config
DefaultTOML is the default toml config
var MaxLengthHostID = 64
MaxLengthHostID is the maximum length of host id
var MaxLengthUserID = 32
MaxLengthUserID is the maximum length of user id
Functions ¶
func CheckAccountName ¶
CheckAccountName checkes whether user name is valid or not
func CheckHostID ¶
CheckHostID checkes whether HostRegistry.ID is valid or not
func CheckUserID ¶
CheckUserID checkes whether UserRegistry.ID is valid or not
func CreateRSAPrivateKey ¶
func CreateRSAPrivateKey(bits int) (privateKey *rsa.PrivateKey, err error)
CreateRSAPrivateKey makes RSA private key
func EncodePrivateKey ¶
func EncodePrivateKey(privateKey *rsa.PrivateKey) ([]byte, error)
EncodePrivateKey encode private key as pem format
func EncodePublicKey ¶
EncodePublicKey generates public key string
func FindSignerInSSHAgentFromFile ¶
FindSignerInSSHAgentFromFile will find signer from ssh agent with public key file
func FindSignerInSSHAgentFromPublicKey ¶
func FindSignerInSSHAgentFromPublicKey(publicKey saultssh.PublicKey) ( signer saultssh.Signer, err error, )
FindSignerInSSHAgentFromPublicKey will find signer from ssh agent with public key
func FingerprintMD5PublicKey ¶
FingerprintMD5PublicKey makes md5 finterprint string of ssh public key; from https://github.com/golang/go/issues/12292#issuecomment-255588529 //
func FingerprintSHA256PublicKey ¶
FingerprintSHA256PublicKey makes the sha256 fingerprint string of ssh public key; from https://github.com/golang/go/issues/12292#issuecomment-255588529
func GetAuthorizedKey ¶
GetAuthorizedKey strips the public key string
func GetDefaultLogrusFormatter ¶
GetDefaultLogrusFormatter return the default logrus formatter
func GetServerLogrusFormatter ¶
GetServerLogrusFormatter return the server logrus formatter
func GetSignerFromPrivateKey ¶
GetSignerFromPrivateKey loads private key signer from string
func LoadPrivateKeySignerWithPasspharaseTrial ¶
func LoadPrivateKeySignerWithPasspharaseTrial(privateKeyFile string) (signer saultssh.Signer, err error)
LoadPrivateKeySignerWithPasspharaseTrial load private key with passphrase
func LoadPublicKeyFromPrivateKeyFile ¶
LoadPublicKeyFromPrivateKeyFile loads public key from private key with passpharase
func MakeFirstLowerCase ¶
MakeFirstLowerCase replace the first char to lower case
func MakeFirstUpperCase ¶
MakeFirstUpperCase replace the first char to upper case
func MakeOutputString ¶
MakeOutputString makes output string for sault client
func MakePascalCase ¶
MakePascalCase make the underscore connected string, 'pascal_case' to 'PascalCase'
func MakeRandomString ¶
func MakeRandomString() string
MakeRandomString makes random string, based on md5 and uuid
func ParseBooleanString ¶
ParseBooleanString parse the boolean string to bool
func ParseHostAccount ¶
ParseHostAccount splits the `@` connected account and host name
func ParseMinusName ¶
ParseMinusName parse the minus string to bool
func ParsePublicKey ¶
ParsePublicKey parses string and makes PublicKey
func ParseSaultAccountName ¶
ParseSaultAccountName splits the `+` connected account and host name
func PrintfInstance ¶
func PrintfInstance(format string, data ...interface{})
PrintfInstance will format and print instance
func ReadPassword ¶
ReadPassword read password from terminal
func SimpleTemplating ¶
SimpleTemplating help to apply string to template
func SplitHostPort ¶
SplitHostPort is similar to net.SplitHostPort, but it can parse without ":port"
func SprintInstance ¶
func SprintInstance(data interface{}) string
SprintInstance will make instance to string
func SprintfInstance ¶
SprintfInstance will format instance
func StringFilter ¶
StringFilter was from https://gobyexample.com/collection-functions
func Templating ¶
Templating help to apply string to template
Types ¶
type CommandError ¶
type CommandError struct { Type CommandErrorType Message string }
CommandError is err
func NewCommandError ¶
func NewCommandError(errType CommandErrorType, message string) *CommandError
NewCommandError create CommandError
func (*CommandError) Error ¶
func (e *CommandError) Error() string
type CommandErrorType ¶
type CommandErrorType uint
CommandErrorType is err type
const ( // CommandErrorNone is none error CommandErrorNone CommandErrorType = iota + 1 // CommandErrorCommon is common error CommandErrorCommon // CommandErrorDialError is connection error CommandErrorDialError // CommandErrorAuthFailed is authentication error CommandErrorAuthFailed // CommandErrorInjectClientKey is injecting error CommandErrorInjectClientKey // CommandErrorPermissionDenied is permission error CommandErrorPermissionDenied )
type CommandMsg ¶
CommandMsg is command message
func NewCommandMsg ¶
func NewCommandMsg(name string, data interface{}) (msg *CommandMsg, err error)
NewCommandMsg create CommandMsg
func (*CommandMsg) GetData ¶
func (msg *CommandMsg) GetData(out interface{}) (err error)
GetData decode data to out
type DefaultLogrusFormatter ¶
DefaultLogrusFormatter is the default logrus formatter
type FlagPrivateKey ¶
FlagPrivateKey is for public key
func (*FlagPrivateKey) Set ¶
func (f *FlagPrivateKey) Set(file string) (err error)
Set is method for flagSet flag
func (*FlagPrivateKey) String ¶
func (f *FlagPrivateKey) String() string
type FlagSaultServer ¶
FlagSaultServer is for sault server address
func (*FlagSaultServer) Set ¶
func (f *FlagSaultServer) Set(v string) error
Set is method for flagSet flag
func (*FlagSaultServer) String ¶
func (f *FlagSaultServer) String() string
type HostAndUserNotLinked ¶
HostAndUserNotLinked means host and user is not linked
func (*HostAndUserNotLinked) Error ¶
func (e *HostAndUserNotLinked) Error() string
type HostDoesNotExistError ¶
HostDoesNotExistError means host does not exist
func (*HostDoesNotExistError) Error ¶
func (e *HostDoesNotExistError) Error() string
type HostExistError ¶
type HostExistError struct {
ID string
}
HostExistError means host exist
func (*HostExistError) Error ¶
func (e *HostExistError) Error() string
type HostNothingToUpdate ¶
type HostNothingToUpdate struct {
ID string
}
HostNothingToUpdate means almost same with the target host
func (*HostNothingToUpdate) Error ¶
func (e *HostNothingToUpdate) Error() string
type InvalidAccountNameError ¶
type InvalidAccountNameError struct {
Name string
}
InvalidAccountNameError means wrong accout name
func (*InvalidAccountNameError) Error ¶
func (e *InvalidAccountNameError) Error() string
type InvalidHostAddressError ¶
InvalidHostAddressError means wrong host address
func (*InvalidHostAddressError) Error ¶
func (e *InvalidHostAddressError) Error() string
type InvalidHostIDError ¶
type InvalidHostIDError struct {
ID string
}
InvalidHostIDError means wrong host id
func (*InvalidHostIDError) Error ¶
func (e *InvalidHostIDError) Error() string
type InvalidUserIDError ¶
type InvalidUserIDError struct {
ID string
}
InvalidUserIDError means wrong user id
func (*InvalidUserIDError) Error ¶
func (e *InvalidUserIDError) Error() string
type LinkedAllError ¶
type LinkedAllError struct { }
LinkedAllError means failed to link
func (*LinkedAllError) Error ¶
func (e *LinkedAllError) Error() string
type ResponseMsg ¶
type ResponseMsg struct { Data interface{} Err *ResponseMsgError }
ResponseMsg is response message
func NewResponseMsg ¶
func NewResponseMsg(result interface{}, errType CommandErrorType, e error) *ResponseMsg
NewResponseMsg create ResponseMsg
func (*ResponseMsg) ToJSON ¶
func (r *ResponseMsg) ToJSON() ([]byte, error)
ToJSON produces json strings
type ResponseMsgError ¶
type ResponseMsgError struct { ErrorType CommandErrorType Message string }
ResponseMsgError is response message error
func (*ResponseMsgError) Error ¶
func (r *ResponseMsgError) Error() string
func (*ResponseMsgError) IsError ¶
func (r *ResponseMsgError) IsError(errType CommandErrorType) bool
IsError checks error type
type SSHAgentNotRunning ¶
type SSHAgentNotRunning struct {
E error
}
SSHAgentNotRunning means ssh agent is not running
func (*SSHAgentNotRunning) Error ¶
func (e *SSHAgentNotRunning) Error() string
func (*SSHAgentNotRunning) PrintWarning ¶
func (e *SSHAgentNotRunning) PrintWarning()
PrintWarning prints warning message
type SSHClient ¶
SSHClient is the wrapper of ssh.Cilent
func NewSSHClient ¶
NewSSHClient creates SSHClient
func (*SSHClient) AddAuthMethod ¶
func (s *SSHClient) AddAuthMethod(auths ...saultssh.AuthMethod)
AddAuthMethod add AuthMethod
func (*SSHClient) SetTimeout ¶
SetTimeout set timeout
type UserDoesNotExistError ¶
UserDoesNotExistError means user does not exists
func (*UserDoesNotExistError) Error ¶
func (e *UserDoesNotExistError) Error() string
type UserExistsError ¶
UserExistsError means user exist
func (*UserExistsError) Error ¶
func (e *UserExistsError) Error() string
type UserNothingToUpdate ¶
type UserNothingToUpdate struct {
ID string
}
UserNothingToUpdate means almost same with the target user
func (*UserNothingToUpdate) Error ¶
func (e *UserNothingToUpdate) Error() string