Documentation ¶
Index ¶
- Variables
- type ExecError
- type Execute
- type Executor
- type FakeExecute
- func (e *FakeExecute) CheckExecutable() error
- func (e *FakeExecute) CmdPath() string
- func (e *FakeExecute) DisableBinCheck()
- func (e *FakeExecute) ExecWithContext(_ context.Context) (*Result, error)
- func (e *FakeExecute) GetCmd() string
- func (e *FakeExecute) SetArgs(a []string)
- func (e *FakeExecute) SetEnv(env []string)
- func (e *FakeExecute) SetExitCode(i int)
- func (e *FakeExecute) SetQuiet()
- func (e *FakeExecute) SetStderr(b []byte)
- func (e *FakeExecute) SetStdin(r io.Reader)
- func (e *FakeExecute) SetStdout(b []byte)
- func (e *FakeExecute) SetVerbose()
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCommandOutput = errors.New("command returned no output") ErrVersionStrExpectedSemver = errors.New("expected version string to follow semver format") ErrFakeExecutorInvalidArgs = errors.New("invalid number of args passed to fake executor") ErrRepositoryBaseURL = errors.New("repository base URL undefined, ensure UpdateOptions.BaseURL OR UPDATE_BASE_URL env var is set") ErrNoUpdatesApplicable = errors.New("no updates applicable") ErrDmiDecodeRun = errors.New("error running dmidecode") ErrComponentListExpected = errors.New("expected a list of components to apply updates") ErrDeviceInventory = errors.New("failed to collect device inventory") ErrUnsupportedDiskVendor = errors.New("unsupported disk vendor") ErrNoUpdateHandlerForComponent = errors.New("component slug has no update handler declared") ErrBinNotExecutable = errors.New("bin has no executable bit set") ErrBinLstat = errors.New("failed to run lstat on bin") ErrBinLookupPath = errors.New("failed to lookup bin path") )
Functions ¶
This section is empty.
Types ¶
type ExecError ¶
ExecError is returned when the command exits with an error or a non zero exit status
type Execute ¶
type Execute struct { Cmd string Args []string Env []string Stdin io.Reader CheckBin bool Quiet bool }
An execute instace
func (*Execute) CheckExecutable ¶
CheckExecutable determines if the set Cmd value exists as a file and is an executable.
func (*Execute) ExecWithContext ¶
ExecWithContext executes the command and returns the Result object
type Executor ¶
type Executor interface { ExecWithContext(context.Context) (*Result, error) SetArgs([]string) SetEnv([]string) GetCmd() string CheckExecutable() error SetStdout([]byte) }
Executor interface lets us implement dummy executors for tests
func NewExecutor ¶
func NewFakeExecutor ¶
type FakeExecute ¶
type FakeExecute struct { Cmd string Args []string Env []string CheckBin bool Stdin io.Reader Stdout []byte // Set this for the dummy data to be returned Stderr []byte // Set this for the dummy data to be returned Quiet bool ExitCode int }
FakeExecute implements the utils.Executor interface to enable testing
func (*FakeExecute) CheckExecutable ¶
func (e *FakeExecute) CheckExecutable() error
CheckExecutable implements the Executor interface
func (*FakeExecute) CmdPath ¶
func (e *FakeExecute) CmdPath() string
CmdPath returns the absolute path to the executable this means the caller should not have disabled CheckBin.
func (*FakeExecute) DisableBinCheck ¶
func (e *FakeExecute) DisableBinCheck()
func (*FakeExecute) ExecWithContext ¶
func (e *FakeExecute) ExecWithContext(_ context.Context) (*Result, error)
nolint:gocyclo // TODO: break this method up and move into each $util_test.go FakeExecute method returns whatever you want it to return Set e.Stdout and e.Stderr to data to be returned
func (*FakeExecute) GetCmd ¶
func (e *FakeExecute) GetCmd() string
func (*FakeExecute) SetArgs ¶
func (e *FakeExecute) SetArgs(a []string)
func (*FakeExecute) SetEnv ¶
func (e *FakeExecute) SetEnv(env []string)
func (*FakeExecute) SetExitCode ¶
func (e *FakeExecute) SetExitCode(i int)
func (*FakeExecute) SetQuiet ¶
func (e *FakeExecute) SetQuiet()
func (*FakeExecute) SetStderr ¶
func (e *FakeExecute) SetStderr(b []byte)
func (*FakeExecute) SetStdin ¶
func (e *FakeExecute) SetStdin(r io.Reader)
func (*FakeExecute) SetStdout ¶
func (e *FakeExecute) SetStdout(b []byte)
func (*FakeExecute) SetVerbose ¶
func (e *FakeExecute) SetVerbose()