Documentation
¶
Index ¶
- Variables
- func Base64IfNotPrintable(val []byte) string
- func BuildInfo() *build.Info
- func DumpJSONIndent(data any) error
- func DumpJSONIndentedFormatted(data []byte, indent int) error
- func DumpMapStrings(data map[string]string, leftPad int)
- func Ed25519KeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)
- func Ed25519KeyPairFromSeed(seed []byte) (ed25519.PublicKey, ed25519.PrivateKey, error)
- func Ed25519KeyPairFromSeedFile(f string) (ed25519.PublicKey, ed25519.PrivateKey, error)
- func Ed25519KeyPairToFile(f string) (ed25519.PublicKey, ed25519.PrivateKey, error)
- func Ed25519Sign(pk ed25519.PrivateKey, msg []byte) ([]byte, error)
- func Ed25519SignWithSeedFile(f string, msg []byte) ([]byte, error)
- func Ed25519Verify(pk ed25519.PublicKey, msg []byte, sig []byte) (bool, error)
- func ExecuteTemplateFile(file string, data any, funcs template.FuncMap) ([]byte, error)
- func ExpandPath(p string) (string, error)
- func FileExist(path string) bool
- func FileHasSha256Sum(path string, sum string) (bool, string, error)
- func FileIsDir(path string) bool
- func FileIsRegular(path string) bool
- func FuncMap(f map[string]any) template.FuncMap
- func GovernorSubject(name string, collective string) string
- func HasPrefix(s string, prefixes ...string) bool
- func HomeDir() (string, error)
- func InterruptibleSleep(ctx context.Context, d time.Duration) error
- func IsEncodedEd25519Key(k []byte) bool
- func IsEncodedEd25519KeyString(k string) bool
- func IsExecutableInPath(c string) bool
- func IsPrintable(s string) bool
- func IterateStringsMap(data map[string]string, cb func(k string, v string))
- func LongestString(list []string, max int) int
- func MatchAnyRegex(str []byte, regex []string) bool
- func NewUTF8Table(hdr ...any) *xtablewriter.Table
- func NewUTF8TableWithTitle(title string, hdr ...any) *xtablewriter.Table
- func ParagraphPadding(paragraph string, padding int) string
- func ParseDuration(dstr string) (dur time.Duration, err error)
- func PromptForConfirmation(format string, a ...any) (bool, error)
- func RenderDuration(d time.Duration) string
- func Sha256ChecksumDir(dir string) ([]byte, error)
- func Sha256HashBytes(c []byte) (string, error)
- func Sha256HashFile(path string) (string, error)
- func Sha256VerifyDir(sumsFile string, dir string, log *logrus.Entry, cb FileReportHandler) (bool, error)
- func SliceGroups(input []string, size int, fn func(group []string))
- func SliceVerticalGroups(input []string, size int, fn func(group []string))
- func StrToBool(s string) (bool, error)
- func StringInList(list []string, match string) bool
- func StringsMapKeys(data map[string]string) []string
- func UniqueID() (id string)
- func UniqueStrings(items []string, shouldSort bool) []string
- func UserConfig() string
- func ValidateSchemaFromFS(schemaPath string, data any) (errors []string, err error)
- type FileReportHandler
Constants ¶
This section is empty.
Variables ¶
var ( ErrorInvalidSumsFile = fmt.Errorf("invalid sums file") ErrorChecksumError = fmt.Errorf("could not checksum file") )
var ( // ErrSchemaUnknown indicates the schema could not be found ErrSchemaUnknown = errors.New("unknown schema") // ErrSchemaValidationFailed indicates that the validator failed to perform validation, perhaps due to invalid schema ErrSchemaValidationFailed = errors.New("validation failed") )
var ConstantBackOffForTests = backoff.Policy{ Millis: []int{25}, }
Functions ¶
func Base64IfNotPrintable ¶ added in v0.23.0
Base64IfNotPrintable returns a string value that's either the given value or base64 encoded if not IsPrintable()
func DumpJSONIndent ¶ added in v0.22.0
DumpJSONIndent dumps data to stdout as indented JSON
func DumpJSONIndentedFormatted ¶ added in v0.26.2
func DumpMapStrings ¶
DumpMapStrings shows k: v of a map[string]string left padded by int, the k will be right aligned and value left aligned
func Ed25519KeyPair ¶ added in v0.26.2
func Ed25519KeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)
func Ed25519KeyPairFromSeed ¶ added in v0.26.2
func Ed25519KeyPairFromSeedFile ¶ added in v0.26.2
func Ed25519KeyPairToFile ¶ added in v0.26.2
func Ed25519Sign ¶ added in v0.26.2
func Ed25519Sign(pk ed25519.PrivateKey, msg []byte) ([]byte, error)
func Ed25519SignWithSeedFile ¶ added in v0.26.2
func Ed25519Verify ¶ added in v0.27.0
func ExecuteTemplateFile ¶ added in v0.27.0
func ExpandPath ¶
ExpandPath expands a path that starts in ~ to the users homedir
func FileHasSha256Sum ¶ added in v0.25.0
FileHasSha256Sum verifies that path has the checksum provided, sum should be hex encoded
func FileIsRegular ¶
func GovernorSubject ¶ added in v0.24.0
GovernorSubject the subject to use for choria managed Governors within a collective
func HomeDir ¶
HomeDir determines the home location without using the user package or requiring cgo
On Unix it needs HOME set and on windows HOMEDRIVE and HOMEDIR
func InterruptibleSleep ¶
InterruptibleSleep sleep for the duration in a way that can be interrupted by the context. An error is returned if the context cancels the sleep
func IsEncodedEd25519Key ¶ added in v0.28.0
func IsEncodedEd25519KeyString ¶ added in v0.28.0
func IsExecutableInPath ¶ added in v0.25.0
func IsPrintable ¶ added in v0.23.0
IsPrintable determines if a string is printable
func IterateStringsMap ¶
IterateStringsMap iterates a map[string]string in key sorted order
func LongestString ¶
LongestString determines the length of the longest string in list, capped at max
func MatchAnyRegex ¶
MatchAnyRegex checks str against a list of possible regex, if any match true is returned
func NewUTF8Table ¶ added in v0.26.0
func NewUTF8Table(hdr ...any) *xtablewriter.Table
NewUTF8Table creates a table formatted with UTF8 styling
func NewUTF8TableWithTitle ¶ added in v0.26.0
func NewUTF8TableWithTitle(title string, hdr ...any) *xtablewriter.Table
NewUTF8TableWithTitle creates a table formatted with UTF8 styling with a title set
func ParagraphPadding ¶ added in v0.22.0
ParagraphPadding pads paragraph with padding spaces
func ParseDuration ¶ added in v0.22.0
ParseDuration is an extended version of go duration parsing that also supports w,W,d,D,M,Y,y in addition to what go supports
func PromptForConfirmation ¶ added in v0.23.0
PromptForConfirmation asks for confirmation on the CLI
func RenderDuration ¶ added in v0.25.0
RenderDuration create a string similar to what %v on a duration would but it supports years, months, etc. Being that days and years are influenced by leap years and such it will never be 100% accurate but for feedback on the terminal its sufficient
func Sha256ChecksumDir ¶ added in v0.28.0
Sha256ChecksumDir produce a file similar to those produced by sha256sum on the command line.
This function will walk the directory and checksum all files in all subdirectories
func Sha256HashBytes ¶ added in v0.25.0
Sha256HashBytes computes the sha256 sum of the byes c and returns the hex encoded result
func Sha256HashFile ¶ added in v0.25.0
Sha256HashFile computes the sha256 sum of a hash and returns the hex encoded result
func Sha256VerifyDir ¶ added in v0.28.0
func Sha256VerifyDir(sumsFile string, dir string, log *logrus.Entry, cb FileReportHandler) (bool, error)
Sha256VerifyDir verifies the sums in sumsFile relative to dir, sumsFile should have been made using Sha256ChecksumDir
When dir is supplied the files in that dir will be verified else the path will be relative to the path of the sumsFile
func SliceGroups ¶
SliceGroups takes a slice of words and make new chunks of given size and call the function with the sub slice. If there are not enough items in the input slice empty strings will pad the last group
func SliceVerticalGroups ¶ added in v0.23.0
SliceVerticalGroups takes a slice of words and make new chunks of given size and call the function with the sub slice. The results are ordered for vertical alignment. If there are not enough items in the input slice empty strings will pad the last group
func StringInList ¶
StringInList checks if match is in list
func StringsMapKeys ¶
StringsMapKeys returns the keys from a map[string]string in sorted order
func UniqueID ¶
func UniqueID() (id string)
UniqueID creates a new unique ID, usually a v4 uuid, if that fails a random string based ID is made
func UniqueStrings ¶
func UserConfig ¶ added in v0.24.0
func UserConfig() string
UserConfig determines what is the active config file for a user