Documentation ¶
Index ¶
- Constants
- Variables
- func GetReplayService(basedir string) (ssh.Service, error)
- func GetServiceTarget(target *url.Resource) *url.Resource
- func New() endly.Service
- func NewSSHMultiRecordingContext(manager endly.Manager, sessions map[string]*url.Resource) (*endly.Context, error)
- func NewSSHMultiReplayContext(manager endly.Manager, sessions map[string]*url.Resource) (*endly.Context, error)
- func NewSSHRecodingContext(manager endly.Manager, target *url.Resource, sessionDir string) (*endly.Context, error)
- func NewSSHReplayContext(manager endly.Manager, target *url.Resource, basedir string) (*endly.Context, error)
- func OperatingSystem(context *endly.Context, sessionName string) *model.OperatingSystem
- func SessionID(context *endly.Context, target *url.Resource) string
- func SetDefaultTarget(context *endly.Context, target *url.Resource)
- func TerminalSession(context *endly.Context, target *url.Resource) (*model.Session, error)
- func TerminalSessions(context *endly.Context) model.Sessions
- type CloseSessionRequest
- type CloseSessionResponse
- type Command
- type ExtractCommand
- type ExtractRequest
- type Log
- type OpenSessionRequest
- type OpenSessionResponse
- type Options
- type RunRequest
- type RunResponse
- type SetTargetRequest
- type SetTargetResponse
- type StdinEvent
- type StdoutEvent
Constants ¶
const ServiceID = "exec"
ServiceID represent system executor service id
const SudoCredentialKey = "**sudo**"
SudoCredentialKey represent obsucated password sudo credentials key (target.Credentials)
Variables ¶
var CommandErrors = []string{util.CommandNotFound, util.NoSuchFileOrDirectory, util.ErrorIsNotRecoverable}
Functions ¶
func GetReplayService ¶
GetReplayService return replay service
func GetServiceTarget ¶ added in v0.41.0
GetServiceTarget sets default target URL, credentials if emtpy
func NewSSHMultiRecordingContext ¶
func NewSSHMultiRecordingContext(manager endly.Manager, sessions map[string]*url.Resource) (*endly.Context, error)
NewSSHMultiRecordingContext open multi recorded session
func NewSSHMultiReplayContext ¶
func NewSSHMultiReplayContext(manager endly.Manager, sessions map[string]*url.Resource) (*endly.Context, error)
OpenMultiSessionTestContext opens test context with multi SSH replay/mocks session
func NewSSHRecodingContext ¶
func NewSSHRecodingContext(manager endly.Manager, target *url.Resource, sessionDir string) (*endly.Context, error)
NewSSHRecodingContext open recorder context (to capture SSH command)
func NewSSHReplayContext ¶
func NewSSHReplayContext(manager endly.Manager, target *url.Resource, basedir string) (*endly.Context, error)
NewSSHReplayContext opens test context with SSH commands to replay
func OperatingSystem ¶
func OperatingSystem(context *endly.Context, sessionName string) *model.OperatingSystem
Os returns operating system for provide session
func SetDefaultTarget ¶ added in v0.41.0
func TerminalSession ¶
TerminalSession returns Session for passed in target resource.
Types ¶
type CloseSessionRequest ¶
type CloseSessionRequest struct {
SessionID string
}
CloseSessionRequest closes session
type CloseSessionResponse ¶
type CloseSessionResponse struct {
SessionID string
}
CloseSessionResponse closes session response
type Command ¶
type Command string
Command represents a command expression: [when criteria ?] command
func (Command) WhenAndCommand ¶
WhenAndCommand extract when criteria and command
type ExtractCommand ¶
type ExtractCommand struct { When string `description:"only run this command is criteria is matched i.e $stdout:/password/"` //only run this execution is output from a previous command is matched Command string `required:"true" description:"shell command to be executed"` //command to be executed Extract model.Extracts `description:"stdout data extraction instruction"` //Stdout data extraction instruction Errors []string `description:"fragments that will terminate execution with error if matched with standard output, in most cases leave empty"` //fragments that will terminate execution with error if matched with standard output Success []string `` //if specified absence of all of the these fragment will terminate execution with error. /* 126-byte string literal not displayed */ }
Extracts represents an execution instructions
func NewExtractCommand ¶
func NewExtractCommand(command, when string, success, errors []string, extractions ...*model.Extract) *ExtractCommand
NewExtractCommand creates a new extract command
func (*ExtractCommand) Init ¶
func (c *ExtractCommand) Init() error
type ExtractRequest ¶
type ExtractRequest struct { Target *url.Resource `required:"true" description:"host where command runs" ` //execution target - destination where to run a command. *Options Commands []*ExtractCommand `description:"command with data extraction instruction "` //extract command }
ExtractRequest represents managed command request
func NewExtractRequest ¶
func NewExtractRequest(target *url.Resource, options *Options, commands ...*ExtractCommand) *ExtractRequest
NewExtractRequest returns a new command request
func NewExtractRequestFromURL ¶
func NewExtractRequestFromURL(URL string) (*ExtractRequest, error)
NewExtractRequestFromURL creates a new request from URL
func (*ExtractRequest) Clone ¶
func (r *ExtractRequest) Clone(target *url.Resource) *ExtractRequest
Clones clones requst with supplide target
func (*ExtractRequest) Validate ¶
func (r *ExtractRequest) Validate() error
Validate validates managed command request
type Log ¶
Log represents an executed command with Stdin, Stdout or Error
func NewCommandLog ¶
NewCommandLog creates a new command log
type OpenSessionRequest ¶
type OpenSessionRequest struct { Target *url.Resource //Session is created from target host (servername, port) Config *ssh.SessionConfig //ssh configuration SystemPaths []string //system path that are applied to the ssh session Env map[string]string Transient bool //if this flag is true, caller is responsible for closing session, othewise session is closed as context is closed Basedir string //capture all ssh service command in supplied dir (for unit test only) ReplayService ssh.Service //use Ssh ReplayService instead of actual SSH service (for unit test only) }
OpenSessionRequest represents an open session request.
func NewOpenSessionRequest ¶
func NewOpenSessionRequest(target *url.Resource, systemPaths []string, env map[string]string, transient bool, basedir string) *OpenSessionRequest
NewOpenSessionRequest creates a new session if transient flag is true, caller is responsible for closing session, otherwise session is closed as context is closed
func (*OpenSessionRequest) Validate ¶
func (r *OpenSessionRequest) Validate() error
Validate checks if request is valid
type OpenSessionResponse ¶
type OpenSessionResponse struct {
SessionID string
}
OpenSessionResponse represents a session id
type Options ¶
type Options struct { SystemPaths []string `description:"path that will be appended to the current SSH execution session the current and future commands"` //path that will be added to the system paths Terminators []string `` //fragment that helps identify that command has been completed - the best is to leave it empty, which is the detected bash prompt /* 141-byte string literal not displayed */ Errors []string `description:"fragments that will terminate execution with error if matched with standard output, in most cases leave empty"` //fragments that will terminate execution with error if matched with standard output TimeoutMs int `description:"time after command was issued for waiting for command output if expect fragment were not matched"` //time after command was issued for waiting for command output if expect fragment were not matched. Directory string `description:"directory where this command should start - if does not exists there is no exception"` //directory where command should run Env map[string]string `description:"environment variables to be set before command runs"` //environment variables to be set before command runs SuperUser bool `` ///flag to run it as super user /* 156-byte string literal not displayed */ Secrets secret.Secrets `description:"secrets map see https://github.com/viant/toolbox/tree/master/secret"` CheckError bool `description:"check after command execution if status is <> 0, then throws error"` AutoSudo bool `description:"when this flag is set, in case of permission denied error for non root user retry command with sudo"` }
Options represents an execution options
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions creates a default execution options
type RunRequest ¶
type RunRequest struct { Target *url.Resource `required:"true" description:"host where command runs" ` //execution target - destination where to run a command. *Options Commands []Command `required:"true" description:"command list" ` //list of commands to run Extract model.Extracts `description:"stdout data extraction instruction"` //Stdout data extraction instruction }
RunRequest represents a simple command
func NewRunRequest ¶
func NewRunRequest(target *url.Resource, superUser bool, commands ...string) *RunRequest
NewRunRequest creates a new request
func NewRunRequestFromURL ¶
func NewRunRequestFromURL(URL string) (*RunRequest, error)
NewExtractRequestFromURL creates a new request from URL
func (*RunRequest) AsExtractRequest ¶
func (r *RunRequest) AsExtractRequest() *ExtractRequest
AsExtractRequest returns ExtractRequest for this requests
func (*RunRequest) Validate ¶
func (r *RunRequest) Validate() error
Validate validates managed command request
type RunResponse ¶
RunResponse represents a command response with logged commands.
func NewRunResponse ¶
func NewRunResponse(session string) *RunResponse
NewRunResponse creates a new RunResponse
func (*RunResponse) Add ¶
func (i *RunResponse) Add(log *Log)
Add appends provided log into commands slice.
func (*RunResponse) Stdout ¶
func (i *RunResponse) Stdout(indexes ...int) string
Stdout returns stdout for provided index, or all concatenated otherwise
type SetTargetRequest ¶ added in v0.41.0
SetTargetRequest represents set default target request
type SetTargetResponse ¶ added in v0.41.0
type SetTargetResponse struct{}
SetTargetRequest represents set default target response
type StdinEvent ¶
StdinEvent represents an execution event start
func NewSdtinEvent ¶
func NewSdtinEvent(sessionID string, stdin string) *StdinEvent
NewSdtinEvent crates a new execution start event value
func (*StdinEvent) Messages ¶
func (e *StdinEvent) Messages() []*msg.Message
Messages returns messages
type StdoutEvent ¶
StdoutEvent represents an execution event end
func NewStdoutEvent ¶
func NewStdoutEvent(sessionID string, stdout string, err error) *StdoutEvent
NewStdoutEvent crates a new execution start event value
func (*StdoutEvent) Messages ¶
func (e *StdoutEvent) Messages() []*msg.Message
Messages returns messages