util

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	Debug    bool
	LogLevel string
)
View Source
var (
	Token string
)

Functions

func AddDebugFlag

func AddDebugFlag()

func AddLogLevelFlag

func AddLogLevelFlag()

func AddModels

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

AddModels adds the child model to parent

func AddTokenFlag

func AddTokenFlag()

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(url string) (string, error, int)

Curl url

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 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 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 ParseIntegerListToStringSlice

func ParseIntegerListToStringSlice(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

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