Documentation ¶
Index ¶
- Constants
- Variables
- func ParseExecOutputFormat(s string) (string, error)
- type ExecCmd
- type ExecCollection
- type ExecResult
- func (e *ExecResult) Dump(format string) (string, error)
- func (e *ExecResult) GetCmd() []string
- func (e *ExecResult) GetCmdString() string
- func (e *ExecResult) GetReturnCode() int
- func (e *ExecResult) GetStdErrByteSlice() []byte
- func (e *ExecResult) GetStdErrString() string
- func (e *ExecResult) GetStdOutByteSlice() []byte
- func (e *ExecResult) GetStdOutString() string
- func (e *ExecResult) SetReturnCode(rc int)
- func (e *ExecResult) SetStdErr(data []byte)
- func (e *ExecResult) SetStdOut(data []byte)
- func (e *ExecResult) String() string
- type Stdout
Constants ¶
const ( ExecFormatJSON string = "json" ExecFormatPlain string = "plain" )
Variables ¶
var ErrRunExecNotSupported = errors.New("exec not supported for this kind")
Functions ¶
func ParseExecOutputFormat ¶
ParseExecOutputFormat parses the exec output format user input.
Types ¶
type ExecCmd ¶
type ExecCmd struct {
Cmd []string `json:"cmd"` // Cmd is a slice-based representation of a string command.
}
ExecCmd represents an exec command.
func NewExecCmdFromSlice ¶
NewExecCmdFromSlice creates ExecCmd for a command represented as a slice of strings.
func NewExecCmdFromString ¶
NewExecCmdFromString creates ExecCmd for a string-based command.
func (*ExecCmd) GetCmdString ¶
GetCmdString sets the command that is to be executed.
type ExecCollection ¶
type ExecCollection struct {
// contains filtered or unexported fields
}
ExecCollection represents a datastore for exec commands execution results.
func NewExecCollection ¶
func NewExecCollection() *ExecCollection
NewExecCollection initializes the collection of exec command results.
func (*ExecCollection) Add ¶
func (ec *ExecCollection) Add(cId string, e *ExecResult)
func (*ExecCollection) AddAll ¶
func (ec *ExecCollection) AddAll(cId string, e []*ExecResult)
func (*ExecCollection) Dump ¶
func (ec *ExecCollection) Dump(format string) (string, error)
Dump dumps the contents of ExecCollection as a string in one of the provided formats.
func (*ExecCollection) Log ¶
func (ec *ExecCollection) Log()
Log writes to the log execution results stored in ExecCollection. If execution result contains error, the error log facility is used, otherwise it is logged as INFO.
type ExecResult ¶
type ExecResult struct { Cmd []string `json:"cmd"` ReturnCode int `json:"return-code"` Stdout Stdout `json:"stdout"` Stderr string `json:"stderr"` }
ExecResult represents a result of a command execution.
func NewExecResult ¶
func NewExecResult(op *ExecCmd) *ExecResult
func (*ExecResult) Dump ¶
func (e *ExecResult) Dump(format string) (string, error)
Dump dumps execution result as a string in one of the provided formats.
func (*ExecResult) GetCmd ¶
func (e *ExecResult) GetCmd() []string
func (*ExecResult) GetCmdString ¶
func (e *ExecResult) GetCmdString() string
GetCmdString returns the initially parsed cmd as a string for e.g. log output purpose.
func (*ExecResult) GetReturnCode ¶
func (e *ExecResult) GetReturnCode() int
func (*ExecResult) GetStdErrByteSlice ¶
func (e *ExecResult) GetStdErrByteSlice() []byte
func (*ExecResult) GetStdErrString ¶
func (e *ExecResult) GetStdErrString() string
func (*ExecResult) GetStdOutByteSlice ¶
func (e *ExecResult) GetStdOutByteSlice() []byte
func (*ExecResult) GetStdOutString ¶
func (e *ExecResult) GetStdOutString() string
func (*ExecResult) SetReturnCode ¶
func (e *ExecResult) SetReturnCode(rc int)
func (*ExecResult) SetStdErr ¶
func (e *ExecResult) SetStdErr(data []byte)
func (*ExecResult) SetStdOut ¶
func (e *ExecResult) SetStdOut(data []byte)
func (*ExecResult) String ¶
func (e *ExecResult) String() string
type Stdout ¶ added in v0.35.0
type Stdout string
Stdout type alias for a string is an artificial type to allow for custom marshalling of stdout output which can be either a valid or non valid JSON. For that reason a custom MarshalJSON method is implemented to take care of both.
func (Stdout) MarshalJSON ¶ added in v0.35.0
MarshalJSON implements a custom marshaller for a custom Stdout type.