Documentation
¶
Overview ¶
Package util contains multiple utils for Fish
Index ¶
- Constants
- func Contains(list []string, value string) bool
- func CreateLock(lockPath string) error
- func DotSerialize(prefix string, in any) map[string]string
- func FileCopy(src string, dst string) error
- func FileReplaceBlock(path, blockFrom, blockTo string, lines ...string) error
- func FileReplaceToken(path string, fullLine, add, anycase bool, tokenValues ...string) error
- func FileStartsWith(path string, prefix []byte) error
- func RunAndLog(section string, timeout time.Duration, stdin io.Reader, path string, ...) (string, string, error)
- func RunAndLogRetry(section string, retry int, timeout time.Duration, stdin io.Reader, path string, ...) (stdout string, stderr string, err error)
- func SerializeMetadata(format, prefix string, data map[string]any) (out []byte, err error)
- func WaitLock(lockPath string, clean func()) error
- type Duration
- type HumanSize
- type PassThruMonitor
- type StreamLogMonitor
- type UnparsedJSON
Constants ¶
const ( B HumanSize = 1 KB = B << 10 MB = KB << 10 GB = MB << 10 TB = GB << 10 PB = TB << 10 EB = PB << 10 )
Definitions of different byte sizes and some maximums
Variables ¶
This section is empty.
Functions ¶
func CreateLock ¶
CreateLock creates the lock file, notice - remove it yourself
func DotSerialize ¶
DotSerialize serializes data to get map as key.subkey=value with dot separation for the keys
func FileReplaceBlock ¶
FileReplaceBlock is a simple block replace in the file
func FileReplaceToken ¶
FileReplaceToken simple replaces tocken in the file
func FileStartsWith ¶
FileStartsWith checks the file starts with required prefix
func RunAndLog ¶ added in v0.7.6
func RunAndLog(section string, timeout time.Duration, stdin io.Reader, path string, arg ...string) (string, string, error)
RunAndLog Runs & logs the executable command
func RunAndLogRetry ¶ added in v0.7.6
func RunAndLogRetry(section string, retry int, timeout time.Duration, stdin io.Reader, path string, arg ...string) (stdout string, stderr string, err error)
Will retry on error and store the retry output and errors to return
func SerializeMetadata ¶
SerializeMetadata serializes dictionary to usable format
Types ¶
type Duration ¶ added in v0.7.3
Duration is a simple wrapper to add serialization functions
func (Duration) MarshalJSON ¶ added in v0.7.3
MarshalJSON represents Duration as JSON string
func (*Duration) StoreStringDuration ¶ added in v0.8.1
StoreStringDuration parses a duration string into a duration Example: "10d", "-1.5w" or "3Y4M5d" Added time units: d(D), w(W), M, y(Y)
func (*Duration) UnmarshalJSON ¶ added in v0.7.3
UnmarshalJSON parses JSON string as Duration
type HumanSize ¶ added in v0.7.5
type HumanSize uint64
HumanSize describes data size In Human Form
func NewHumanSize ¶ added in v0.7.5
NewHumanSize creates human size for you
func (HumanSize) MarshalText ¶ added in v0.7.5
MarshalText represents HumanSize as string
func (*HumanSize) UnmarshalText ¶ added in v0.7.5
UnmarshalText converts text to HumanSize number To be properly parsed the text should contain number and unit ("B", "KB", "MB"...) in the end
type PassThruMonitor ¶
type PassThruMonitor struct {
io.Reader
Name string // Prefix for the message
Length int64 // Expected length
// contains filtered or unexported fields
}
PassThruMonitor wraps an existing io.Reader to monitor the stream
It simply forwards the Read() call, while displaying the results from individual calls to it.
type StreamLogMonitor ¶ added in v0.7.2
type StreamLogMonitor struct {
Prefix string // Prefix for the line
// contains filtered or unexported fields
}
StreamLogMonitor wraps an existing io.Reader to monitor the log stream and adds prefix before each line
type UnparsedJSON ¶ added in v0.7.5
type UnparsedJSON string
UnparsedJSON is used to store json as is and not parse it until the right time
func (UnparsedJSON) MarshalJSON ¶ added in v0.7.5
func (r UnparsedJSON) MarshalJSON() ([]byte, error)
MarshalJSON represents UnparsedJson as bytes
func (*UnparsedJSON) UnmarshalJSON ¶ added in v0.7.5
func (r *UnparsedJSON) UnmarshalJSON(b []byte) error
UnmarshalJSON converts bytes to UnparsedJson
func (*UnparsedJSON) UnmarshalYAML ¶ added in v0.7.5
func (r *UnparsedJSON) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML is needed to properly convert incoming yaml requests into json