Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = SessionConfig{ // contains filtered or unexported fields }
var DefaultTransportConfig = TransportConfig{}
Functions ¶
This section is empty.
Types ¶
type FactoryImpl ¶
type FactoryImpl struct {
// contains filtered or unexported fields
}
func (FactoryImpl) NewSession ¶
func (f FactoryImpl) NewSession(ctx context.Context, sshcfg *ssh.ClientConfig, target string, opts ...SessionOption, ) (s Session, err error)
type SSHTransport ¶
type SSHTransport interface { io.WriteCloser io.Reader }
func NewSSHTransport ¶
func NewSSHTransport(ctx context.Context, sshcfg *ssh.ClientConfig, cfg *TransportConfig, target string) (SSHTransport, error)
type SendConfig ¶
type SendConfig struct {
// contains filtered or unexported fields
}
SendConfig defines properties controlling Send behaviour.
type SendOption ¶
type SendOption func(*SendConfig)
SendOption implements options for configuring Send behaviour.
func NoNewline ¶
func NoNewline() SendOption
NoNewline suppresses the newline that is by default appended to the Send string.
func ResetPrompt ¶
func ResetPrompt() SendOption
ResetPrompt resets the current session prompt to the last unterminated line of response.
func WaitFor ¶
func WaitFor(sentinel string) SendOption
WaitFor defines the string that indicates the end of the response to the send. Defaults to the current prompt.
type Session ¶
type Session interface { // Send writes the supplied value to the server and returns the response. // The behaviour can be modified by opts - see SendOption variants below. Send(value string, opts ...SendOption) (string, error) io.Closer }
Session defines the API exposed by an SSH client.
type SessionConfig ¶
type SessionConfig struct {
// contains filtered or unexported fields
}
SessionConfig defines properties controlling session behaviour.
type SessionFactory ¶
type SessionFactory interface {
NewSession(ctx context.Context, sshcfg *ssh.ClientConfig, target string, opts ...SessionOption) (s Session, err error)
}
func NewSessionFactory ¶
func NewSessionFactory(cfg *SessionConfig) SessionFactory
type SessionImpl ¶
type SessionImpl struct {
// contains filtered or unexported fields
}
func NewCliSession ¶
func NewCliSession(ctx context.Context, tport SSHTransport, cfg *SessionConfig) (s *SessionImpl, err error)
NewCliSession establishes a client connection to a cli session running on the server associated with the supplied transport.
func (*SessionImpl) Close ¶
func (s *SessionImpl) Close() error
func (*SessionImpl) Send ¶
func (s *SessionImpl) Send(output string, opts ...SendOption) (string, error)
type SessionOption ¶
type SessionOption func(*SessionConfig)
SessionOption implements options for configuring session behaviour.
func WithCommands ¶
func WithCommands(cmds ...string) SessionOption
WithCommand defines initialisation commands to be executed after a session has been established.
func WithPrompt ¶
func WithPrompt(pattern string) SessionOption
WithPrompt overrides the automatic prompt detection that a new client session applies to determine the cli prompt that is used to detect the end of a server response. A non-empty pattern value defines a regular expression that will be used to detect the cli prompt. An empty pattern indicates the the WaitFor option when calling Send.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) SessionOption
WithTimeout defines the length of time to wait without receiving any input that is used to determine that the server has completed a response. Typically, only used when auto-detecting the cli prompt.
type TransportConfig ¶
type TransportConfig struct{}