util

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAllObfuscatorsTested

func AssertAllObfuscatorsTested(t *testing.T, obfuscators []*obfuscate.Obfuscator)

func AssertObfuscation

func AssertObfuscation(t *testing.T, obfuscators []*obfuscate.Obfuscator,
	kind obfuscate.Kind, name, input, expected string)

AssertObfuscation is a helper function for tests where we want to validate if obfuscation.Obfuscator works correctly.

func AssertObfuscationExample

func AssertObfuscationExample(t *testing.T, obfuscators []*obfuscate.Obfuscator, kind obfuscate.Kind, name string)

AssertObfuscationExample uses AssertObfuscation to assert but loads the example automatically from testdata.

Parameter `name` must correspond to the relative file name under testdata, or in case of a command, spaces are replaced by a minus sign, and txt is used for the file extension.

func CommandExists

func CommandExists(cmd string) bool

CommandExists returns true if command exists.

func GetHostnameWithoutDomain

func GetHostnameWithoutDomain() string

GetHostnameWithoutDomain returns hostname without domain.

func IsPrivilegedUser

func IsPrivilegedUser() bool

IsPrivilegedUser returns true when the current user is root.

func LoadTestdata

func LoadTestdata(t *testing.T, name string) string

LoadTestdata loads a file from the testdata directory and returns its contents as string.

Intended to load text file for comparison in assertions.

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice matches if a string is contained in a slice.

Types

type ExtraLogHook

type ExtraLogHook struct {
	Formatter logrus.Formatter
	Writer    io.Writer
	Level     logrus.Level
}

func (ExtraLogHook) Fire

func (h ExtraLogHook) Fire(entry *logrus.Entry) error

func (ExtraLogHook) Levels

func (h ExtraLogHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL