Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CmdExecutor ¶
type CmdExecutor interface { RunCmd(cmd interface{}, opts ...Options) (string, string, error) SetLevel(level logrus.Level) RunCmdWithAttempts(cmd interface{}, attempts int, timeout time.Duration, opts ...Options) (string, string, error) }
CmdExecutor is the interface for executor that runs linux commands with RunCmd
type CmdName ¶
type CmdName string
CmdName represents command name without specified arguments
func (CmdName) Apply ¶
func (c CmdName) Apply(opt *CmdOptions)
Apply assigns CmdName to given CmdOptions Receive CmdOptions
type CmdOptions ¶
CmdOptions encapsulates options for executing command
func (*CmdOptions) ApplyOptions ¶
func (o *CmdOptions) ApplyOptions(opts []Options)
ApplyOptions applies given options for CmdOptions struct Receive list of options
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor is the implementation of CmdExecutor based on os/exec package
func NewExecutor ¶
NewExecutor is a constructor for executor
func (*Executor) RunCmd ¶
RunCmd runs specified command on OS Receives command as empty interface. It could be string or instance of exec.Cmd Returns stdout as string, stderr as string and golang error if something went wrong
func (*Executor) RunCmdWithAttempts ¶
func (e *Executor) RunCmdWithAttempts(cmd interface{}, attempts int, timeout time.Duration, opts ...Options) (string, string, error)
RunCmdWithAttempts runs specified command on OS with given attempts and timeout between attempts Receives command as empty interface, It could be string or instance of exec.Cmd; number of attempts; timeout. Returns stdout as string, stderr as string and golang error if something went wrong
type Options ¶
type Options interface {
Apply(*CmdOptions)
}
Options represents interface for applying options
type UseMetrics ¶
type UseMetrics bool
UseMetrics represents options to use metrics in executor
func (UseMetrics) Apply ¶
func (u UseMetrics) Apply(opt *CmdOptions)
Apply assigns UseMetrics to given CmdOptions Receive CmdOptions