channel

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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 (l *LocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)

func (*LocalChannel) GetPidsByProcessName

func (l *LocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)

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)

func (*LocalChannel) Run

func (l *LocalChannel) Run(ctx context.Context, script, args string) *spec.Response

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 (mlc *MockLocalChannel) GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)

func (*MockLocalChannel) GetPidsByProcessName

func (mlc *MockLocalChannel) GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)

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)

func (*MockLocalChannel) Run

func (mlc *MockLocalChannel) Run(ctx context.Context, script, args string) *spec.Response

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

Jump to

Keyboard shortcuts

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