Documentation
¶
Index ¶
- Constants
- func AliasCommandRun(src *cobra.Command) func(cmd *cobra.Command, args []string)
- func AliasCommandRunE(src *cobra.Command) func(cmd *cobra.Command, args []string) error
- func AliasCommandUse(aliasOf *cobra.Command, name ...string) string
- func AliasOf(src *cobra.Command, name ...string) *cobra.Command
- func ChownAll(path string, uid, gid int) error
- func CloseCommonFds(ctx context.Context, parentPID, childPID int32) error
- func Confirm(ctx context.Context, msg string) bool
- func CopyFile(src, dest string) error
- func FileMD5Sum(path string) (string, error)
- func FillHost(ctx context.Context, state *daemon.Host) error
- func FillProcessState(ctx context.Context, pid uint32, state *daemon.ProcessState, tree ...bool) error
- func FullUse(cmd *cobra.Command) string
- func FunctionName(pc uintptr) string
- func GRPCError(err error, extra ...string) error
- func GRPCErrorColored(err error, extra ...string) error
- func GRPCErrorColoredShort(err error, extra ...string) error
- func GRPCErrorShort(err error, extra ...string) error
- func GetCmd(ctx context.Context, pid uint32) (string, []string, error)
- func GetCredentials() (*syscall.Credential, error)
- func GetFreePort() (int, error)
- func GetHost(ctx context.Context) (*daemon.Host, error)
- func GetMACAddress() (string, error)
- func GetProcessState(ctx context.Context, pid uint32, tree ...bool) (*daemon.ProcessState, error)
- func GetRootCredentials() *syscall.Credential
- func GetSID(pid uint32) (uint32, error)
- func GetTag(i any, field string, tag string) string
- func GetValue(i any, field string) any
- func Getenv(env []string, key string, defaultValue ...string) string
- func Gibibytes(bytes int64) int64
- func HasActiveTCPConnections(pid uint32) (bool, error)
- func Int32ToIntSlice(slice []int32) []int
- func Int32ToUint32Slice(slice []int32) []uint32
- func IntToInt32Slice(slice []int) []int32
- func IntToUint32Slice(slice []int) []uint32
- func IsCallerSameAsUs(caller string) bool
- func IsRootUser() bool
- func IsTTY(path string) (bool, error)
- func Kibibytes(bytes int64) int64
- func LastLine(s string) string
- func ListFields(i any, tag ...string) []string
- func ListFilesInDir(dir string) ([]string, error)
- func ListLeaves(i any, tag ...string) []string
- func LoadJSONFromFile(path string, data any, fs ...afero.Fs) error
- func LogProtoMessage(msg proto.Message, subject string, level zerolog.Level)
- func Mebibytes(bytes int64) int64
- func ParseHttpBody(body io.ReadCloser) (string, error)
- func PathExists(path string) bool
- func PidExists(pid uint32) bool
- func PidRunning(pid uint32) bool
- func ProtoToJSON(payload any) string
- func SaveJSONToFile(data any, path string, fs ...afero.Fs) error
- func SimplifyFuncName(f string) (category string, name string)
- func SizeFromPath(path string) int64
- func SizeStr(bytes int64) string
- func StrList(strs []string) string
- func StringToUint32Slice(slice []string) []uint32
- func TimeAgo(t time.Time) string
- func Uint32ToStringSlice(slice []uint32) []string
- func VSOCKDialer(contextId uint32, port uint32) func(context.Context, string) (net.Conn, error)
- func WaitForFile[T any](ctx context.Context, path string, timeout <-chan T) ([]byte, error)
- func WaitForPid(pid uint32) chan int
- func WaitForPidCtx(ctx context.Context, pid uint32) chan int
- func WalkTree[T any](node any, valuesField string, childrenField string, fn func(T) bool) bool
- type FdInfo
- type HttpBody
- type LinkDep
Constants ¶
const ( BYTE = 1.0 << (10 * iota) KIBIBYTE MEBIBYTE GIBIBYTE )
const MaxTimeAgo = 24 * 365 * 20 * time.Hour // 20 years
Variables ¶
This section is empty.
Functions ¶
func AliasCommandRun ¶ added in v0.9.237
Use this for Run to make a command an alias to another command's Run. Invokes all persistent hooks for all parents as well.
func AliasCommandRunE ¶ added in v0.9.237
Use this for RunE to make a command an alias to another command's RunE. Invokes all persistent hooks for all parents as well.
func AliasCommandUse ¶ added in v0.9.237
func AliasOf ¶ added in v0.9.237
AliasOf creates an alias of the provided command, That includes the same flags and hooks. Even the parent command's PersistentPreRunE and PersistentPostRunE hooks are invoked. Provide a name only if it's different from provided command's name
func CloseCommonFds ¶ added in v0.9.237
CloseCommonFdscloses any common FDs between the parent and child process
func FileMD5Sum ¶ added in v0.9.237
Computes the MD5 checksum of the given files (read in order)
func FillProcessState ¶ added in v0.9.237
func FillProcessState(ctx context.Context, pid uint32, state *daemon.ProcessState, tree ...bool) error
Tries to fill as much as possible of the process state. Only returns early if the process does not exist at all.
func FunctionName ¶ added in v0.9.237
FunctionName returns the name of the function pointed to by f
func GRPCErrorColored ¶ added in v0.9.237
func GRPCErrorColoredShort ¶ added in v0.9.237
func GRPCErrorShort ¶ added in v0.9.237
func GetCredentials ¶ added in v0.9.237
func GetCredentials() (*syscall.Credential, error)
func GetFreePort ¶ added in v0.9.230
GetFreePort returns a free random port on the host
func GetMACAddress ¶ added in v0.9.225
func GetProcessState ¶ added in v0.9.237
func GetRootCredentials ¶ added in v0.9.237
func GetRootCredentials() *syscall.Credential
func GetTag ¶ added in v0.9.237
GetTag returns the value of the tag with the given name for the field with the given name. Nested fields can be specified by separating them with a period, and the returned tag will also be separated by periods. If the field does not exist, or the tag does not exist, an empty string will be returned.
func GetValue ¶ added in v0.9.237
GetValue returns the value of the field with the given name. If the field does not exist, or is not set, the zero value for the field type will be returned. Nested fields can be specified by separating them with a period.
func HasActiveTCPConnections ¶ added in v0.9.237
Checks if the given process has any active tcp connections
func Int32ToIntSlice ¶ added in v0.9.268
func Int32ToUint32Slice ¶ added in v0.9.237
func IntToInt32Slice ¶ added in v0.9.237
func IntToUint32Slice ¶ added in v0.9.237
func IsCallerSameAsUs ¶ added in v0.9.237
func IsRootUser ¶ added in v0.9.237
func IsRootUser() bool
func ListFields ¶ added in v0.9.237
ListFields returns a list of field names for the given struct. If a tag is specified, it will use the tag value instead of the field name.
func ListFilesInDir ¶ added in v0.9.237
func ListLeaves ¶ added in v0.9.237
LeavesList returns a list of field names for the given struct If a field is a struct, it will recursively call itself to get the fields. If a tag is specified, it will use the tag value instead of the field name. Nested fields are separated by a period.
func LoadJSONFromFile ¶ added in v0.9.237
func LogProtoMessage ¶ added in v0.9.237
func ParseHttpBody ¶ added in v0.9.268
func ParseHttpBody(body io.ReadCloser) (string, error)
func PathExists ¶ added in v0.9.237
func PidRunning ¶ added in v0.9.244
PidRunning checks if a process with the given PID is running
func ProtoToJSON ¶ added in v0.9.237
func SaveJSONToFile ¶ added in v0.9.237
func SimplifyFuncName ¶ added in v0.9.237
SimplifyFuncName simplifies the function name to a category and a name. Removes the long package prefix. If the function belongs to a plugin, the plugin name is returned.
func SizeFromPath ¶ added in v0.9.237
SizeFromPath returns the size of the file or directory at the provided path.
func StringToUint32Slice ¶ added in v0.9.237
func Uint32ToStringSlice ¶ added in v0.9.237
func VSOCKDialer ¶ added in v0.9.237
func WaitForFile ¶ added in v0.9.238
func WaitForPid ¶ added in v0.9.228
Returns a channel that will be closed when a non-child process exits Since, we cannot use the process.Wait() method to wait for a non-child process to exit It waits until the process is a zombie process
func WaitForPidCtx ¶ added in v0.9.237
Returns a channel that will be closed when a non-child process exits. Since, we cannot use the process.Wait() method to wait for a non-child process to exit. It waits until the process is a zombie process, or the process is not found.
func WalkTree ¶ added in v0.9.253
WalkTree recursively walks a tree-structured struct using reflection, calling fn for every element in the specified valuesField slice. If fn returns false, the walk stops immediately. If true, it continues. childrenField specifies which struct field contains the slice of child nodes. The field names should match exactly (including capitalization).