Documentation ¶
Index ¶
- Constants
- func CombineErrors(errs []error, formatErrMsg FormatErrMsgFunc) error
- func Contains(input []interface{}, value interface{}) (bool, error)
- func ConvertKVStrToMapWithNoErr(values []string) map[string]string
- func ConvertKVStringsToMap(values []string) (map[string]string, error)
- func ConvertStrToKV(input string) (string, string, error)
- func DeDuplicate(input []string) []string
- func FormatSize(size int64) string
- func FormatTimeInterval(input int64) (formattedTime string, err error)
- func GetUnixTimestamp(value string, base time.Time) (string, error)
- func If(cond bool, v1, v2 interface{}) interface{}
- func IsFileExist(file string) bool
- func IsMountpoint(dir string) bool
- func IsProcessAlive(pid int) bool
- func KillProcess(pid int)
- func MakeFSVolume(fscmd []string, devicePath string, timeout time.Duration) error
- func Merge(src, dest interface{}) error
- func MountVolume(mountCmd []string, devicePath, mountPath string, timeout time.Duration) error
- func NewPidfile(path string) error
- func ParseTimestamp(value string, defaultSec int64) (int64, int64, error)
- func SetOOMScore(pid, score int) error
- func StringInSlice(input []string, str string) bool
- func StringSliceEqual(s1, s2 []string) bool
- func TruncateID(id string) string
- type FormatErrMsgFunc
Constants ¶
const ( Second = time.Second Minute = Second * 60 Hour = Minute * 60 Day = Hour * 24 Week = Day * 7 Month = Day * 30 Year = Day * 365 TimeLayout = time.RFC3339Nano // RFC3339NanoFixed is our own version of RFC339Nano because we want one // that pads the nano seconds part with zeros to ensure // the timestamps are aligned in the logs. RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" )
Common durations that is . There are some definitions for units of Day and larger .
Variables ¶
This section is empty.
Functions ¶
func CombineErrors ¶
func CombineErrors(errs []error, formatErrMsg FormatErrMsgFunc) error
CombineErrors is a function which used by Inspect to merge multiple errors into one error.
func ConvertKVStrToMapWithNoErr ¶
ConvertKVStrToMapWithNoErr converts input strings and converts them all in a map, When there is invalid input, the dealing procedure ignores the error and log a warning message.
func ConvertKVStringsToMap ¶
ConvertKVStringsToMap converts ["key=value"] into {"key":"value"}
func ConvertStrToKV ¶
ConvertStrToKV converts an string into key and value string without returning an error. For example, for input "a=b", it should return "a", "b".
func DeDuplicate ¶
DeDuplicate make a slice with no duplicated elements.
func FormatTimeInterval ¶
FormatTimeInterval is used to show the time interval from input time to now.
func GetUnixTimestamp ¶
GetUnixTimestamp will parse the value into time and get the nano-timestamp in string.
NOTE: if the value is not relative time, GetUnixTimestamp will use RFC3339 format to parse the value.
func If ¶
func If(cond bool, v1, v2 interface{}) interface{}
If implements ternary operator. if cond is true return v1, or return v2 instead.
func IsMountpoint ¶
IsMountpoint is used to check the directory is mountpoint or not.
func IsProcessAlive ¶
IsProcessAlive returns true if process with a given pid is running.
func MakeFSVolume ¶
MakeFSVolume is used to make file system on device with format type and options.
func Merge ¶
func Merge(src, dest interface{}) error
Merge merge object from src to dest, dest object should be pointer, only accept struct type, notice: src will overwrite dest's data
func MountVolume ¶
MountVolume is used to mount device to directory with options.
func NewPidfile ¶
NewPidfile checks if pidfile exist, and saves daemon pid.
func ParseTimestamp ¶
ParseTimestamp returns seconds and nanoseconds.
- If the value is empty, it will return default second, the second arg.
- If the incoming nanosecond portion is longer or shorter than 9 digits, it will be converted into 9 digits nanoseconds.
func SetOOMScore ¶
SetOOMScore sets process's oom_score value The higher the value of oom_score of any process, the higher is its likelihood of getting killed by the OOM Killer in an out-of-memory situation.
func StringInSlice ¶
StringInSlice checks if a string in the slice.
func StringSliceEqual ¶
StringSliceEqual compare two string slice, ignore the order.
func TruncateID ¶
TruncateID is used to transfer image ID from digest to short ID.