Documentation ¶
Index ¶
- Constants
- type LocalChannel
- func (l *LocalChannel) GetPidUser(pid string) (string, error)
- func (l *LocalChannel) GetPidsByLocalPort(localPort string) ([]string, error)
- func (l *LocalChannel) GetPidsByLocalPorts(localPorts []string) ([]string, error)
- func (l *LocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)
- func (l *LocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)
- func (l *LocalChannel) GetPsArgs() string
- func (l *LocalChannel) GetScriptPath() string
- func (l *LocalChannel) IsCommandAvailable(commandName string) bool
- func (l *LocalChannel) ProcessExists(pid string) (bool, error)
- func (l *LocalChannel) Run(ctx context.Context, script, args string) *spec.Response
- type MockLocalChannel
- func (mlc *MockLocalChannel) GetPidUser(pid string) (string, error)
- func (mlc *MockLocalChannel) GetPidsByLocalPort(localPort string) ([]string, error)
- func (mlc *MockLocalChannel) GetPidsByLocalPorts(localPorts []string) ([]string, error)
- func (mlc *MockLocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)
- func (mlc *MockLocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)
- func (mlc *MockLocalChannel) GetPsArgs() string
- func (mlc *MockLocalChannel) GetScriptPath() string
- func (mlc *MockLocalChannel) IsCommandAvailable(commandName string) bool
- func (mlc *MockLocalChannel) ProcessExists(pid string) (bool, error)
- func (mlc *MockLocalChannel) Run(ctx context.Context, script, args string) *spec.Response
- type OsChannel
Constants ¶
View Source
const ExcludeProcessKey = "excludeProcess"
View Source
const ProcessKey = "process"
grep ${key}
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalChannel ¶
type LocalChannel struct { }
func (*LocalChannel) GetPidUser ¶
func (l *LocalChannel) GetPidUser(pid string) (string, error)
func (*LocalChannel) GetPidsByLocalPort ¶
func (l *LocalChannel) GetPidsByLocalPort(localPort string) ([]string, error)
func (*LocalChannel) GetPidsByLocalPorts ¶
func (l *LocalChannel) GetPidsByLocalPorts(localPorts []string) ([]string, error)
func (*LocalChannel) GetPidsByProcessCmdName ¶
func (*LocalChannel) GetPidsByProcessName ¶
func (*LocalChannel) GetPsArgs ¶
func (l *LocalChannel) GetPsArgs() string
func (*LocalChannel) GetScriptPath ¶
func (l *LocalChannel) GetScriptPath() string
func (*LocalChannel) IsCommandAvailable ¶
func (l *LocalChannel) IsCommandAvailable(commandName string) bool
func (*LocalChannel) ProcessExists ¶
func (l *LocalChannel) ProcessExists(pid string) (bool, error)
type MockLocalChannel ¶
type MockLocalChannel struct { ScriptPath string // mock function RunFunc func(ctx context.Context, script, args string) *spec.Response GetPidsByProcessCmdNameFunc func(processName string, ctx context.Context) ([]string, error) GetPidsByProcessNameFunc func(processName string, ctx context.Context) ([]string, error) GetPsArgsFunc func() string IsCommandAvailableFunc func(commandName string) bool ProcessExistsFunc func(pid string) (bool, error) GetPidUserFunc func(pid string) (string, error) GetPidsByLocalPortsFunc func(localPorts []string) ([]string, error) GetPidsByLocalPortFunc func(localPort string) ([]string, error) }
MockLocalChannel for testing
func (*MockLocalChannel) GetPidUser ¶
func (mlc *MockLocalChannel) GetPidUser(pid string) (string, error)
func (*MockLocalChannel) GetPidsByLocalPort ¶
func (mlc *MockLocalChannel) GetPidsByLocalPort(localPort string) ([]string, error)
func (*MockLocalChannel) GetPidsByLocalPorts ¶
func (mlc *MockLocalChannel) GetPidsByLocalPorts(localPorts []string) ([]string, error)
func (*MockLocalChannel) GetPidsByProcessCmdName ¶
func (*MockLocalChannel) GetPidsByProcessName ¶
func (*MockLocalChannel) GetPsArgs ¶
func (mlc *MockLocalChannel) GetPsArgs() string
func (*MockLocalChannel) GetScriptPath ¶
func (mlc *MockLocalChannel) GetScriptPath() string
func (*MockLocalChannel) IsCommandAvailable ¶
func (mlc *MockLocalChannel) IsCommandAvailable(commandName string) bool
func (*MockLocalChannel) ProcessExists ¶
func (mlc *MockLocalChannel) ProcessExists(pid string) (bool, error)
type OsChannel ¶
type OsChannel interface { spec.Channel // GetPidsByProcessCmdName returns the matched process other than the current process by the program command GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error) // GetPidsByProcessName returns the matched process other than the current process by the process keyword GetPidsByProcessName(processName string, ctx context.Context) ([]string, error) // GetPsArgs returns the ps command output format GetPsArgs() string // IsCommandAvailable returns true if the command exists IsCommandAvailable(commandName string) bool // ProcessExists returns true if the pid exists, otherwise return false. ProcessExists(pid string) (bool, error) // GetPidUser returns the process user by pid GetPidUser(pid string) (string, error) // GetPidsByLocalPorts returns the process ids using the ports GetPidsByLocalPorts(localPorts []string) ([]string, error) // GetPidsByLocalPort returns the process pid corresponding to the port GetPidsByLocalPort(localPort string) ([]string, error) // contains filtered or unexported methods }
func NewLocalChannel ¶
func NewLocalChannel() OsChannel
NewLocalChannel returns a local channel for invoking the host command
func NewMockLocalChannel ¶
func NewMockLocalChannel() OsChannel
Click to show internal directories.
Click to hide internal directories.