Documentation ¶
Index ¶
- Constants
- func CreateScriptFile(scriptDir, scriptContent string, interpreter Interpreter, ...) (filePath string, err error)
- func GetGidByName(group string) (gid uint32, err error)
- func GetScriptExtensionOS(interpreter Interpreter) string
- func GetUIDByName(name string) (uid uint32, err error)
- func HasShebangLine(script string) bool
- func IsPortOpen(hostPort string, timeout time.Duration) (bool, error)
- func PercentIOWait(lastCall *LastCallCPU) ([]float64, error)
- func ValidateScriptDir(scriptDir string) error
- func ValidateScriptDirOS(scriptDirSysInfo os.FileInfo, scriptDir string) error
- type CPUInfo
- type CmdExecutor
- type CmdExecutorContext
- type CmdExecutorImpl
- type Interpreter
- type LastCallCPU
- type MockSystemInfo
- func (s *MockSystemInfo) CPUInfo(ctx context.Context) (CPUInfo, error)
- func (s *MockSystemInfo) CPUPercent(ctx context.Context) (float64, error)
- func (s *MockSystemInfo) CPUPercentIOWait(ctx context.Context) (float64, error)
- func (s *MockSystemInfo) GoArch() string
- func (s *MockSystemInfo) HostInfo(ctx context.Context) (*host.InfoStat, error)
- func (s *MockSystemInfo) Hostname() (string, error)
- func (s *MockSystemInfo) InterfaceAddrs() ([]net.Addr, error)
- func (s *MockSystemInfo) MemoryStats(ctx context.Context) (*mem.VirtualMemoryStat, error)
- func (s *MockSystemInfo) SystemTime() time.Time
- func (s *MockSystemInfo) Uname(ctx context.Context) (string, error)
- func (s *MockSystemInfo) VirtualizationInfo(ctx context.Context) (virtSystem, virtRole string, err error)
- type ShellEncoding
- type SysInfo
- type SysUserLookup
- type SysUserProvider
Constants ¶
View Source
const ( VirtualSystemHyperV = "HyperV" VirtualSystemVMWare = "VMware" VirtualSystemKVM = "KVM" VirtualSystemXen = "Xen" VirtualSystemRoleGuest = "guest" VirtualSystemRoleHost = "host" )
View Source
const DefaultDirMode = os.FileMode(0700)
View Source
const DefaultFileMode = os.FileMode(0540)
View Source
const UnknownValue = "unknown"
Variables ¶
This section is empty.
Functions ¶
func CreateScriptFile ¶
func GetGidByName ¶
func GetScriptExtensionOS ¶
func GetScriptExtensionOS(interpreter Interpreter) string
func GetUIDByName ¶
func HasShebangLine ¶
HasShebangLine is just for making code more readable
func IsPortOpen ¶
IsPortOpen returns (true, nil) if a given TCP port is open on a given host. (false, err) - otherwise or if timeout is reached. 'hostPort' is in format <host>:<port>
func PercentIOWait ¶
func PercentIOWait(lastCall *LastCallCPU) ([]float64, error)
PercentIOWait calculates the percentage of io-wait combined for all CPU's. The current cpu times are compared against cpu times from the last call.
func ValidateScriptDir ¶
Types ¶
type CmdExecutor ¶
type CmdExecutorContext ¶
type CmdExecutorContext struct { Interpreter Interpreter Command string WorkingDir string IsSudo bool HasShebang bool }
type CmdExecutorImpl ¶
func NewCmdExecutor ¶
func NewCmdExecutor(l *logger.Logger) *CmdExecutorImpl
func (*CmdExecutorImpl) New ¶
func (e *CmdExecutorImpl) New(ctx context.Context, execCtx *CmdExecutorContext) *exec.Cmd
type Interpreter ¶
func (Interpreter) Get ¶
func (i Interpreter) Get() string
func (Interpreter) GetDefault ¶
func (i Interpreter) GetDefault() string
type LastCallCPU ¶
type MockSystemInfo ¶
type MockSystemInfo struct { ReturnHostname string ReturnHostnameError error ReturnHostInfo *host.InfoStat ReturnHostInfoError error ReturnCPUInfo CPUInfo ReturnCPUInfoError error ReturnCPUPercent float64 ReturnCPUPercentError error ReturnCPUPercentIOWait float64 ReturnCPUPercentIOWaitError error ReturnMemoryStat *mem.VirtualMemoryStat ReturnMemoryError error ReturnUname string ReturnUnameError error ReturnInterfaceAddrs []net.Addr ReturnInterfaceAddrsError error ReturnGoArch string ReturnSystemTime time.Time ReturnVirtualizationInfoError error }
func (*MockSystemInfo) CPUInfo ¶
func (s *MockSystemInfo) CPUInfo(ctx context.Context) (CPUInfo, error)
func (*MockSystemInfo) CPUPercent ¶
func (s *MockSystemInfo) CPUPercent(ctx context.Context) (float64, error)
func (*MockSystemInfo) CPUPercentIOWait ¶
func (s *MockSystemInfo) CPUPercentIOWait(ctx context.Context) (float64, error)
func (*MockSystemInfo) GoArch ¶
func (s *MockSystemInfo) GoArch() string
func (*MockSystemInfo) Hostname ¶
func (s *MockSystemInfo) Hostname() (string, error)
func (*MockSystemInfo) InterfaceAddrs ¶
func (s *MockSystemInfo) InterfaceAddrs() ([]net.Addr, error)
func (*MockSystemInfo) MemoryStats ¶
func (s *MockSystemInfo) MemoryStats(ctx context.Context) (*mem.VirtualMemoryStat, error)
func (*MockSystemInfo) SystemTime ¶
func (s *MockSystemInfo) SystemTime() time.Time
func (*MockSystemInfo) VirtualizationInfo ¶
func (s *MockSystemInfo) VirtualizationInfo(ctx context.Context) (virtSystem, virtRole string, err error)
type ShellEncoding ¶
func DetectConsoleEncoding ¶
func DetectConsoleEncoding(ctx context.Context, interpreter Interpreter) (*ShellEncoding, error)
DetectConsoleEncoding returns encoding that interpreter is using. Returns nil, if it's UTF-8
func EncodingFromConfig ¶
func EncodingFromConfig(config clientconfig.InterpreterAliasEncoding) (*ShellEncoding, error)
func (*ShellEncoding) GetInputEncoder ¶
func (e *ShellEncoding) GetInputEncoder() *encoding.Encoder
func (*ShellEncoding) GetOutputDecoder ¶
func (e *ShellEncoding) GetOutputDecoder() *encoding.Decoder
func (*ShellEncoding) String ¶
func (e *ShellEncoding) String() string
type SysInfo ¶
type SysInfo interface { Hostname() (string, error) HostInfo(context.Context) (*host.InfoStat, error) CPUInfo(ctx context.Context) (CPUInfo, error) CPUPercent(ctx context.Context) (float64, error) CPUPercentIOWait(ctx context.Context) (float64, error) MemoryStats(context.Context) (*mem.VirtualMemoryStat, error) Uname(context.Context) (string, error) InterfaceAddrs() ([]net.Addr, error) GoArch() string SystemTime() time.Time VirtualizationInfo(ctx context.Context) (virtSystem, virtRole string, err error) }
func NewSystemInfo ¶
func NewSystemInfo(cmdExec CmdExecutor) SysInfo
type SysUserLookup ¶
type SysUserProvider ¶
type SysUserProvider struct{}
func (SysUserProvider) GetCurrentUserAndGroup ¶
func (SysUserProvider) GetGidByName ¶
func (sup SysUserProvider) GetGidByName(group string) (gid uint32, err error)
func (SysUserProvider) GetUIDByName ¶
func (sup SysUserProvider) GetUIDByName(user string) (uid uint32, err error)
Click to show internal directories.
Click to hide internal directories.