Documentation ¶
Overview ¶
Package otto an automation toolkit for Unix-like computers.
This package contains the common interfaces and methods shared by the Otto client and Otto server.
Index ¶
- Constants
- func DecodeMessage(messageType uint32, data []byte) (interface{}, error)
- func EncodeMessage(messageType uint32, message interface{}) ([]byte, error)
- func ReadMessage(r io.Reader, psk string) (uint32, interface{}, error)
- func WriteMessage(messageType uint32, message interface{}, w io.Writer, psk string) error
- type File
- type MessageActionOutput
- type MessageActionResult
- type MessageCancelAction
- type MessageGeneralFailure
- type MessageHeartbeatRequest
- type MessageHeartbeatResponse
- type MessageTriggerAction
- type RegisterRequest
- type RegisterRequestProperties
- type RegisterResponse
- type RunAs
- type Script
- type ScriptResult
Constants ¶
const ( MessageTypeKeepalive uint32 = iota + 1 MessageTypeHeartbeatRequest MessageTypeHeartbeatResponse MessageTypeTriggerAction MessageTypeCancelAction MessageTypeActionOutput MessageTypeActionResult MessageTypeGeneralFailure )
Message types
const ( ActionRunScript uint32 = iota + 1 ActionReloadConfig ActionUploadFile ActionUploadFileAndExit ActionExit ActionReboot ActionShutdown ActionUpdatePSK )
Actions
const ProtocolVersion = uint32(2)
ProtocolVersion the version of the otto protocol
Variables ¶
This section is empty.
Functions ¶
func DecodeMessage ¶
DecodeMessage try to decode the given message. The returned object should match the message struct for the message type.
func EncodeMessage ¶
EncodeMessage try to encode the given message
func ReadMessage ¶
ReadMessage try to read a message from the given reader. Returns the message type, the message data, or an error
Types ¶
type File ¶
type File struct { Path string `json:"path"` Owner RunAs `json:"owner"` Mode uint32 `json:"mode"` Data []byte `json:"data"` }
File Describes a file
type MessageActionOutput ¶
MessageActionOutput describes output from an action
type MessageActionResult ¶
type MessageActionResult struct { ScriptResult ScriptResult `json:"script_result"` Error error `json:"error"` File File `json:"file"` ClientVersion string `json:"client_version"` }
MessageActionResult describes the result of a triggered action
type MessageCancelAction ¶
type MessageCancelAction struct{}
MessageCancelAction describes a request to cancel an action
type MessageGeneralFailure ¶
type MessageGeneralFailure struct {
Error error `json:"error"`
}
MessageGeneralFailure describes a general failure
type MessageHeartbeatRequest ¶
type MessageHeartbeatRequest struct {
ServerVersion string `json:"server_version"`
}
MessageHeartbeatRequest describes a heartbeat request
type MessageHeartbeatResponse ¶
type MessageHeartbeatResponse struct { ClientVersion string `json:"client_version"` Properties map[string]string `json:"properties"` }
MessageHeartbeatResponse describes a heartbeat response
type MessageTriggerAction ¶
type MessageTriggerAction struct { Action uint32 `json:"action"` Script Script `json:"script"` File File `json:"file"` NewPSK string `json:"new_psk"` }
MessageTriggerAction describes an action trigger
type RegisterRequest ¶
type RegisterRequest struct { Key string `json:"key"` Port uint32 `json:"port"` Properties RegisterRequestProperties `json:"properties"` }
RegisterRequest describes a register request
type RegisterRequestProperties ¶
type RegisterRequestProperties struct { Hostname string `json:"hostname"` KernelName string `json:"kernel_name"` KernelVersion string `json:"kernel_version"` DistributionName string `json:"distribution_name"` DistributionVersion string `json:"distribution_version"` }
RegisterRequestProperties describes properties for a register request
type RegisterResponse ¶
type RegisterResponse struct { PSK string `json:"psk"` Scripts []Script `json:"scripts,omitempty"` }
RegisterResponse describes the response to a register request
type Script ¶
type Script struct { Name string `json:"name"` RunAs RunAs `json:"run_as"` Environment map[string]string `json:"environment"` WorkingDirectory string `json:"working_directory"` Executable string `json:"executable"` Files []File `json:"files"` Data []byte `json:"data"` }
Script describes a script
type ScriptResult ¶
type ScriptResult struct { Success bool `json:"success"` ExecError string `json:"exec_error"` Code int `json:"code"` Stdout string `json:"stdout"` Stderr string `json:"stderr"` Elapsed time.Duration `json:"elapsed"` }
ScriptResult describes the result of the script
func (ScriptResult) String ¶
func (sr ScriptResult) String() string