util

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 29 Imported by: 25

Documentation

Index

Constants

View Source
const (
	Blade  = 1
	Bin    = 2
	Custom = 3
)
View Source
const BladeLog = "chaosblade.log"

Variables

View Source
var (
	Debug    bool
	LogPath  string
	LogLevel string
)

Functions

func AddDebugFlag

func AddDebugFlag()

func AddLogLevelFlag

func AddLogLevelFlag()

func AddLogPathFlag

func AddLogPathFlag()

func AddModels

func AddModels(parent *spec.Models, child *spec.Models)

AddModels adds the child model to parent

func ArchiveTar

func ArchiveTar(file string, writer *tar.Writer) error

func CheckPortInUse

func CheckPortInUse(port string) bool

CheckPortInUse returns true if the port is in use, otherwise returns false.

func ConvertSpecToModels

func ConvertSpecToModels(commandSpec spec.ExpModelCommandSpec, prepare spec.ExpPrepareModel, scope string) *spec.Models

ConvertSpecToModels converts the spec.ExpModelCommandSpec to spec.Models

func CreateYamlFile

func CreateYamlFile(models *spec.Models, specFile string) error

CreateYamlFile converts the spec.Models to spec file

func Curl

func Curl(ctx context.Context, url string) (string, error, int)

Curl url

func Debugf

func Debugf(uid, funcName, msg string)

func Errorf

func Errorf(uid, funcName, msg string)

func Fatalf

func Fatalf(uid, funcName, msg string)

func GenerateContainerId

func GenerateContainerId() string

GenerateContainerId for container

func GenerateExecID

func GenerateExecID() string

func GenerateUid

func GenerateUid() (string, error)

GenerateUid for exp

func GetBinPath

func GetBinPath() string

GetBinPath

func GetLibHome

func GetLibHome() string

GetLibHome

func GetLogFile

func GetLogFile(programType int) (string, error)

GetLogFile

func GetLogPath

func GetLogPath(programType int) (string, error)

func GetNohupOutput

func GetNohupOutput(programType int, logFileName string) string

GetNohupOutput

func GetProgramParentPath

func GetProgramParentPath() string

GetProgramParentPath returns the parent directory end with /

func GetProgramPath

func GetProgramPath() string

GetProgramPath

func GetRunFuncName

func GetRunFuncName() string

func GetSpecifyingUserHome

func GetSpecifyingUserHome(username string) string

GetSpecifyingUserHome

func GetUnusedPort

func GetUnusedPort() (int, error)

func GetUserHome

func GetUserHome() string

GetUserHome return user home.

func GetYamlHome

func GetYamlHome() string

func Hold

func Hold(hooks ...ShutdownHook)

func Infof

func Infof(uid, funcName, msg string)

func InitLog

func InitLog(programType int)

InitLog invoked after flag parsed

func IsDir

func IsDir(path string) bool

IsDir returns true if the path is directory

func IsExist

func IsExist(fileName string) bool

IsExist returns true if file exists

func IsNil

func IsNil(i interface{}) bool

func MarshalModelSpec

func MarshalModelSpec(models *spec.Models, writer io.Writer) error

MarshalModelSpec marshals the spec.Models to bytes and output to writer

func MergeModels

func MergeModels(models ...*spec.Models) *spec.Models

MergeModels

func Panicf

func Panicf(uid, funcName, msg string)

func ParseIntegerListToStringSlice

func ParseIntegerListToStringSlice(flagName, flagValue string) ([]string, error)

ParseIntegerListToStringSlice func parses the multiple integer values to string slice. Support the below formats: 0 | 0,1 | 0,2,3 | 0-3 | 0,2-4 | 0,1,3-5 For example, the flag value is 0,2-3, the func returns []string{"0", "2", "3"}

func ParseSpecsToModel

func ParseSpecsToModel(file string, executor spec.Executor) (*spec.Models, error)

ParseSpecsToModel parses the yaml file to spec.Models and set the executor to the spec.Models

func PostCurl

func PostCurl(url string, body []byte, contentType string) (string, error, int)

PostCurl

func Remove

func Remove(items []string, idx int) []string

Remove the item by the index

func RemoveDuplicates

func RemoveDuplicates(items []string) []string

func Tracef

func Tracef(uid, funcName, msg string)

func Warnf

func Warnf(uid, funcName, msg string)

Types

type ShutdownHook

type ShutdownHook interface {
	Shutdown() error
}

Jump to

Keyboard shortcuts

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