commandexecutor

package
v0.218.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashService

type BashService struct {
	CommandExecutorBase
}

func Bash

func Bash() (b *BashService)

Can be used to run commands in bash on localhost.

func NewBashService

func NewBashService() (b *BashService)

func (*BashService) GetDeepCopy

func (b *BashService) GetDeepCopy() (deepCopy CommandExecutor)

func (*BashService) GetHostDescription

func (b *BashService) GetHostDescription() (hostDescription string, err error)

func (*BashService) MustGetHostDescription

func (b *BashService) MustGetHostDescription() (hostDescription string)

func (*BashService) MustRunCommand

func (b *BashService) MustRunCommand(options *parameteroptions.RunCommandOptions) (commandOutput *CommandOutput)

func (*BashService) MustRunOneLiner

func (b *BashService) MustRunOneLiner(oneLiner string, verbose bool) (output *CommandOutput)

func (*BashService) MustRunOneLinerAndGetStdoutAsLines

func (b *BashService) MustRunOneLinerAndGetStdoutAsLines(oneLiner string, verbose bool) (stdoutLines []string)

func (*BashService) MustRunOneLinerAndGetStdoutAsString

func (b *BashService) MustRunOneLinerAndGetStdoutAsString(oneLiner string, verbose bool) (stdout string)

func (*BashService) RunCommand

func (b *BashService) RunCommand(options *parameteroptions.RunCommandOptions) (commandOutput *CommandOutput, err error)

func (*BashService) RunOneLiner

func (b *BashService) RunOneLiner(oneLiner string, verbose bool) (output *CommandOutput, err error)

func (*BashService) RunOneLinerAndGetStdoutAsLines

func (b *BashService) RunOneLinerAndGetStdoutAsLines(oneLiner string, verbose bool) (stdoutLines []string, err error)

func (*BashService) RunOneLinerAndGetStdoutAsString

func (b *BashService) RunOneLinerAndGetStdoutAsString(oneLiner string, verbose bool) (stdout string, err error)

type CommandExecutor

type CommandExecutor interface {
	GetHostDescription() (hostDescription string, err error)
	RunCommand(options *parameteroptions.RunCommandOptions) (commandOutput *CommandOutput, err error)
	MustGetHostDescription() (hostDescription string)
	MustRunCommand(options *parameteroptions.RunCommandOptions) (commandOutput *CommandOutput)

	// These Commands can be implemented by embedding the `CommandExecutorBase` struct:
	IsRunningOnLocalhost() (isRunningOnLocalhost bool, err error)
	MustIsRunningOnLocalhost() (isRunningOnLocalhost bool)
	MustRunCommandAndGetStdoutAsBytes(options *parameteroptions.RunCommandOptions) (stdout []byte)
	MustRunCommandAndGetStdoutAsFloat64(options *parameteroptions.RunCommandOptions) (stdout float64)
	MustRunCommandAndGetStdoutAsInt64(options *parameteroptions.RunCommandOptions) (stdout int64)
	MustRunCommandAndGetStdoutAsLines(options *parameteroptions.RunCommandOptions) (stdoutLines []string)
	MustRunCommandAndGetStdoutAsString(options *parameteroptions.RunCommandOptions) (stdout string)
	RunCommandAndGetStdoutAsBytes(options *parameteroptions.RunCommandOptions) (stdout []byte, err error)
	RunCommandAndGetStdoutAsFloat64(options *parameteroptions.RunCommandOptions) (stdout float64, err error)
	RunCommandAndGetStdoutAsInt64(options *parameteroptions.RunCommandOptions) (stdout int64, err error)
	RunCommandAndGetStdoutAsLines(options *parameteroptions.RunCommandOptions) (stdoutLines []string, err error)
	RunCommandAndGetStdoutAsString(options *parameteroptions.RunCommandOptions) (stdout string, err error)
}

A CommandExecutor is able to run a command like Exec or bash does.

func GetDeepCopyOfCommandExecutor

func GetDeepCopyOfCommandExecutor(commandExectuor CommandExecutor) (copy CommandExecutor, err error)

func MustGetDeepCopyOfCommandExecutor

func MustGetDeepCopyOfCommandExecutor(commandExectuor CommandExecutor) (copy CommandExecutor)

type CommandExecutorBase

type CommandExecutorBase struct {
	// contains filtered or unexported fields
}

func NewCommandExecutorBase

func NewCommandExecutorBase() (c *CommandExecutorBase)

func (*CommandExecutorBase) GetParentCommandExecutorForBaseClass

func (c *CommandExecutorBase) GetParentCommandExecutorForBaseClass() (parentCommandExecutorForBaseClass CommandExecutor, err error)

func (*CommandExecutorBase) IsRunningOnLocalhost

func (c *CommandExecutorBase) IsRunningOnLocalhost() (isRunningOnLocalhost bool, err error)

func (*CommandExecutorBase) MustGetParentCommandExecutorForBaseClass

func (c *CommandExecutorBase) MustGetParentCommandExecutorForBaseClass() (parentCommandExecutorForBaseClass CommandExecutor)

func (*CommandExecutorBase) MustIsRunningOnLocalhost

func (c *CommandExecutorBase) MustIsRunningOnLocalhost() (isRunningOnLocalhost bool)

func (*CommandExecutorBase) MustRunCommandAndGetStdoutAsBytes

func (c *CommandExecutorBase) MustRunCommandAndGetStdoutAsBytes(options *parameteroptions.RunCommandOptions) (stdout []byte)

func (*CommandExecutorBase) MustRunCommandAndGetStdoutAsFloat64

func (c *CommandExecutorBase) MustRunCommandAndGetStdoutAsFloat64(options *parameteroptions.RunCommandOptions) (stdout float64)

func (*CommandExecutorBase) MustRunCommandAndGetStdoutAsInt64

func (c *CommandExecutorBase) MustRunCommandAndGetStdoutAsInt64(options *parameteroptions.RunCommandOptions) (stdout int64)

func (*CommandExecutorBase) MustRunCommandAndGetStdoutAsLines

func (c *CommandExecutorBase) MustRunCommandAndGetStdoutAsLines(options *parameteroptions.RunCommandOptions) (stdoutLines []string)

func (*CommandExecutorBase) MustRunCommandAndGetStdoutAsString

func (c *CommandExecutorBase) MustRunCommandAndGetStdoutAsString(options *parameteroptions.RunCommandOptions) (stdout string)

func (*CommandExecutorBase) MustSetParentCommandExecutorForBaseClass

func (c *CommandExecutorBase) MustSetParentCommandExecutorForBaseClass(parentCommandExecutorForBaseClass CommandExecutor)

func (*CommandExecutorBase) RunCommandAndGetStdoutAsBytes

func (c *CommandExecutorBase) RunCommandAndGetStdoutAsBytes(options *parameteroptions.RunCommandOptions) (stdout []byte, err error)

func (*CommandExecutorBase) RunCommandAndGetStdoutAsFloat64

func (c *CommandExecutorBase) RunCommandAndGetStdoutAsFloat64(options *parameteroptions.RunCommandOptions) (stdout float64, err error)

func (*CommandExecutorBase) RunCommandAndGetStdoutAsInt64

func (c *CommandExecutorBase) RunCommandAndGetStdoutAsInt64(options *parameteroptions.RunCommandOptions) (stdout int64, err error)

func (*CommandExecutorBase) RunCommandAndGetStdoutAsLines

func (c *CommandExecutorBase) RunCommandAndGetStdoutAsLines(options *parameteroptions.RunCommandOptions) (stdoutLines []string, err error)

func (*CommandExecutorBase) RunCommandAndGetStdoutAsString

func (c *CommandExecutorBase) RunCommandAndGetStdoutAsString(options *parameteroptions.RunCommandOptions) (stdout string, err error)

func (*CommandExecutorBase) SetParentCommandExecutorForBaseClass

func (c *CommandExecutorBase) SetParentCommandExecutorForBaseClass(parentCommandExecutorForBaseClass CommandExecutor) (err error)

type CommandOutput

type CommandOutput struct {
	// contains filtered or unexported fields
}

func NewCommandOutput

func NewCommandOutput() (c *CommandOutput)

func (*CommandOutput) CheckExitSuccess

func (o *CommandOutput) CheckExitSuccess(verbose bool) (err error)

func (*CommandOutput) GetCmdRunError

func (c *CommandOutput) GetCmdRunError() (cmdRunError *error, err error)

func (*CommandOutput) GetCmdRunErrorStringOrEmptyStringIfUnset

func (o *CommandOutput) GetCmdRunErrorStringOrEmptyStringIfUnset() (cmdRunErrorString string)

func (*CommandOutput) GetFirstLineOfStdoutAsString

func (c *CommandOutput) GetFirstLineOfStdoutAsString() (firstLine string, err error)

func (*CommandOutput) GetReturnCode

func (o *CommandOutput) GetReturnCode() (returnCode int, err error)

func (*CommandOutput) GetStderr

func (c *CommandOutput) GetStderr() (stderr *[]byte, err error)

func (*CommandOutput) GetStderrAsString

func (o *CommandOutput) GetStderrAsString() (stderr string, err error)

func (*CommandOutput) GetStderrAsStringOrEmptyIfUnset

func (o *CommandOutput) GetStderrAsStringOrEmptyIfUnset() (stderr string)

func (*CommandOutput) GetStdout

func (c *CommandOutput) GetStdout() (stdout *[]byte, err error)

func (*CommandOutput) GetStdoutAsBytes

func (o *CommandOutput) GetStdoutAsBytes() (stdout []byte, err error)

func (*CommandOutput) GetStdoutAsFloat64

func (c *CommandOutput) GetStdoutAsFloat64() (stdout float64, err error)

func (*CommandOutput) GetStdoutAsLines

func (o *CommandOutput) GetStdoutAsLines(removeLastLineIfEmpty bool) (stdoutLines []string, err error)

func (*CommandOutput) GetStdoutAsString

func (o *CommandOutput) GetStdoutAsString() (stdout string, err error)

func (*CommandOutput) IsExitSuccess

func (o *CommandOutput) IsExitSuccess() (isSuccess bool)

func (*CommandOutput) IsStderrEmpty

func (c *CommandOutput) IsStderrEmpty() (isEmpty bool, err error)

func (*CommandOutput) IsStdoutAndStderrEmpty

func (c *CommandOutput) IsStdoutAndStderrEmpty() (isEmpty bool, err error)

func (*CommandOutput) IsStdoutEmpty

func (c *CommandOutput) IsStdoutEmpty() (isEmpty bool, err error)

func (*CommandOutput) IsTimedOut

func (o *CommandOutput) IsTimedOut() (IsTimedOut bool, err error)

func (*CommandOutput) LogStdoutAsInfo

func (c *CommandOutput) LogStdoutAsInfo() (err error)

func (*CommandOutput) MustCheckExitSuccess

func (c *CommandOutput) MustCheckExitSuccess(verbose bool)

func (*CommandOutput) MustGetCmdRunError

func (c *CommandOutput) MustGetCmdRunError() (cmdRunError *error)

func (*CommandOutput) MustGetFirstLineOfStdoutAsString

func (c *CommandOutput) MustGetFirstLineOfStdoutAsString() (firstLine string)

func (*CommandOutput) MustGetReturnCode

func (c *CommandOutput) MustGetReturnCode() (returnCode int)

func (*CommandOutput) MustGetStderr

func (c *CommandOutput) MustGetStderr() (stderr *[]byte)

func (*CommandOutput) MustGetStderrAsString

func (c *CommandOutput) MustGetStderrAsString() (stdout string)

func (*CommandOutput) MustGetStdout

func (c *CommandOutput) MustGetStdout() (stdout *[]byte)

func (*CommandOutput) MustGetStdoutAsBytes

func (c *CommandOutput) MustGetStdoutAsBytes() (stdout []byte)

func (*CommandOutput) MustGetStdoutAsFloat64

func (c *CommandOutput) MustGetStdoutAsFloat64() (stdout float64)

func (*CommandOutput) MustGetStdoutAsLines

func (c *CommandOutput) MustGetStdoutAsLines(removeLastLineIfEmpty bool) (stdoutLines []string)

func (*CommandOutput) MustGetStdoutAsString

func (c *CommandOutput) MustGetStdoutAsString() (stdout string)

func (*CommandOutput) MustIsStderrEmpty

func (c *CommandOutput) MustIsStderrEmpty() (isEmpty bool)

func (*CommandOutput) MustIsStdoutAndStderrEmpty

func (c *CommandOutput) MustIsStdoutAndStderrEmpty() (isEmpty bool)

func (*CommandOutput) MustIsStdoutEmpty

func (c *CommandOutput) MustIsStdoutEmpty() (isEmpty bool)

func (*CommandOutput) MustIsTimedOut

func (c *CommandOutput) MustIsTimedOut() (IsTimedOut bool)

func (*CommandOutput) MustLogStdoutAsInfo

func (c *CommandOutput) MustLogStdoutAsInfo()

func (*CommandOutput) MustSetReturnCode

func (c *CommandOutput) MustSetReturnCode(returnCode int)

func (*CommandOutput) MustSetStderr

func (c *CommandOutput) MustSetStderr(stderr []byte)

func (*CommandOutput) MustSetStderrByString

func (c *CommandOutput) MustSetStderrByString(stderr string)

func (*CommandOutput) MustSetStdout

func (c *CommandOutput) MustSetStdout(stdout []byte)

func (*CommandOutput) MustSetStdoutByString

func (c *CommandOutput) MustSetStdoutByString(stdout string)

func (*CommandOutput) SetCmdRunError

func (o *CommandOutput) SetCmdRunError(err error)

func (*CommandOutput) SetReturnCode

func (o *CommandOutput) SetReturnCode(returnCode int) (err error)

func (*CommandOutput) SetStderr

func (o *CommandOutput) SetStderr(stderr []byte) (err error)

func (*CommandOutput) SetStderrByString

func (o *CommandOutput) SetStderrByString(stderr string) (err error)

func (*CommandOutput) SetStdout

func (o *CommandOutput) SetStdout(stdout []byte) (err error)

func (*CommandOutput) SetStdoutByString

func (o *CommandOutput) SetStdoutByString(stdout string) (err error)

type ExecService

type ExecService struct {
	CommandExecutorBase
}

func Exec

func Exec() (e *ExecService)

func NewExec

func NewExec() (e *ExecService)

func NewExecService

func NewExecService() (e *ExecService)

func (*ExecService) GetDeepCopy

func (e *ExecService) GetDeepCopy() (deepCopy CommandExecutor)

func (*ExecService) GetHostDescription

func (e *ExecService) GetHostDescription() (hostDescription string, err error)

func (*ExecService) MustGetHostDescription

func (e *ExecService) MustGetHostDescription() (hostDescription string)

func (*ExecService) MustRunCommand

func (e *ExecService) MustRunCommand(options *parameteroptions.RunCommandOptions) (commandOutput *CommandOutput)

func (*ExecService) RunCommand

func (e *ExecService) RunCommand(options *parameteroptions.RunCommandOptions) (commandOutput *CommandOutput, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL