Documentation ¶
Index ¶
- Constants
- func GetServiceTarget(target *location.Resource) *location.Resource
- func New() endly.Service
- func OperatingSystem(context *endly.Context, sessionName string) *model.OperatingSystem
- func SessionID(context *endly.Context, target *location.Resource) string
- func TerminalSession(context *endly.Context, target *location.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 = "sudoer"
SudoCredentialKey represent obsucated password sudo credentials key (target.Credentials)
Variables ¶
This section is empty.
Functions ¶
func GetServiceTarget ¶
GetServiceTarget sets default target URL, credentials if emtpy
func OperatingSystem ¶
func OperatingSystem(context *endly.Context, sessionName string) *model.OperatingSystem
Os returns operating system for provide session
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
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 ElseCommand string `required:"true" description:"shell command to be executed when if when criteria is not met"` //shell command to be executed when if when criteria is not met 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 */ Terminators []string `description:"terminators"` TimeoutMs int `description:"timeoutMs stdout wait timeout "` // contains filtered or unexported fields }
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 *location.Resource ` description:"host where command are executed" ` //execution target - destination where to run commands. *Options Commands []*ExtractCommand `description:"command with data extraction instruction "` //extract command }
ExtractRequest represents managed command request
func NewExtractRequest ¶
func NewExtractRequest(target *location.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 *location.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 *location.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) }
OpenSessionRequest represents an open session request.
func NewOpenSessionRequest ¶
func NewOpenSessionRequest(target *location.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 *location.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 *location.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 ¶
SetTargetRequest represents set default target request
type SetTargetResponse ¶
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