helper

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyStringPointer = StringPointer(emptyStringValue)
View Source
var EmptyStringSlicePointer = StringSlicePointer(emptyStringSliceValue)
View Source
var (
	NilMap map[string]string
)

Functions

func AlignRHCSSourceVersion added in v1.5.1

func AlignRHCSSourceVersion(dir string) error

func AssertWaitPollNoErr added in v1.6.3

func AssertWaitPollNoErr(e error, msg string)

func AssertWaitPollWithErr added in v1.6.3

func AssertWaitPollWithErr(e error, msg string)

func BoolPointer added in v1.5.1

func BoolPointer(b bool) *bool

Return a bool pointer of the input bool value

func Contains added in v1.3.0

func Contains(arry []string, val string) (index int, flag bool)

Contains will return bool balue that whether the arry contains string val

func ConvertMapToJSONString added in v1.3.0

func ConvertMapToJSONString(inputMap map[string]interface{}) string

ConvertMapToJSONString converts the map to a json string.

func ConvertStringToInt added in v1.3.0

func ConvertStringToInt(mystring string) int

func ConvertStructToMap added in v1.3.0

func ConvertStructToMap(s interface{}) map[string]interface{}

func ConvertStructToString added in v1.3.0

func ConvertStructToString(s interface{}) string

func CopyStringMap added in v1.6.3

func CopyStringMap(originalMap m) m

Create a file for usage

func CreateFileWithContent added in v1.6.4

func CreateFileWithContent(fileAbsPath string, content interface{}) (string, error)

Write string to a file

func CreatePEMCertificate added in v1.6.5

func CreatePEMCertificate() (string, error)

Create a PEM Certificate Code taken from https://shaneutt.com/blog/golang-ca-and-signed-cert-go/

func CreateTempFileWithContent added in v1.6.4

func CreateTempFileWithContent(fileContent string) (string, error)

func CreateTempFileWithPrefixAndContent added in v1.6.4

func CreateTempFileWithPrefixAndContent(prefix string, fileContent string) (string, error)

func DeleteFile added in v1.5.0

func DeleteFile(filename string) error

Delete a file

func Dig added in v1.3.0

func Dig(object interface{}, keys []interface{}) interface{}

func DigArray added in v1.3.0

func DigArray(object interface{}, keys ...interface{}) []interface{}

DigArray tries to find an array inside the given object with the given path, and returns its value. If there is no attribute with the given path then the test will be aborted with an error.

func DigArrayToInt added in v1.6.3

func DigArrayToInt(object interface{}, keys ...interface{}) []int

func DigArrayToString added in v1.4.0

func DigArrayToString(object interface{}, keys ...interface{}) []string

func DigBool added in v1.3.0

func DigBool(object interface{}, keys ...interface{}) bool

func DigInt added in v1.3.0

func DigInt(object interface{}, keys ...interface{}) int

DigInt tries to find an attribute inside the given object with the given path, and returns its value, assuming that it is an integer. If there is no attribute with the given path then the test will be aborted with an error.

func DigMapToString added in v1.6.3

func DigMapToString(object interface{}, keys ...interface{}) map[string]string

func DigObject added in v1.3.0

func DigObject(object interface{}, keys ...interface{}) interface{}

func DigString added in v1.3.0

func DigString(object interface{}, keys ...interface{}) string

If there is no attribute with the given path then the return value will be an empty string.

func DigStringArray added in v1.3.0

func DigStringArray(object interface{}, keys ...interface{}) []string

DigStringArray tries to find an array inside the given object with the given path, and returns its value. If there is no attribute with the given path then the test will be aborted with an error.

func EndsWith added in v1.3.0

func EndsWith(st string, substring string) (flag bool)

EndsWith will return the bool value that whether the st is end with substring

func ExpectTFErrorContains added in v1.6.3

func ExpectTFErrorContains(err error, substring string)

func Float64Pointer added in v1.5.1

func Float64Pointer(f float64) *float64

func GenerateClusterName added in v1.4.0

func GenerateClusterName(profileName string) string

func GenerateRandomName added in v1.6.3

func GenerateRandomName(prefix string, n int) string

func GenerateRandomPassword added in v1.6.3

func GenerateRandomPassword(length int) string

func GenerateRandomString added in v1.6.3

func GenerateRandomString(n int) string

Generate random string

func GenerateRandomStringWithSymbols added in v1.5.0

func GenerateRandomStringWithSymbols(length int) string

func GetClusterAdminPassword added in v1.5.0

func GetClusterAdminPassword() (string, error)

func GetMajorVersion added in v1.6.5

func GetMajorVersion(rawVersion string) string

func GetProfile added in v1.4.0

func GetProfile(profileName string, profilesDir string) (*profile, error)

func GetRegistries added in v1.6.5

func GetRegistries(ports ...int) (regs []string)

func GetRegistry added in v1.6.5

func GetRegistry(port int) string

func GetTFErrorMessage added in v1.6.3

func GetTFErrorMessage(err error) string

func IntPointer added in v1.5.1

func IntPointer(i int) *int

Return a pointer of the input int value

func IntSlicePointer added in v1.6.3

func IntSlicePointer(f []int) *[]int

func IsFileExists added in v1.6.3

func IsFileExists(filePath string) (bool, error)

func IsInMap added in v1.3.0

func IsInMap(inputMap map[string]interface{}, key string) bool

func IsSorted added in v1.3.0

func IsSorted(arry []string, mode string) (flag bool)

IsSorted will return whether the array is sorted by mode

func Join added in v1.3.0

func Join(s ...string) string

Join will link the strings with "."

func JoinStringWithArray added in v1.5.0

func JoinStringWithArray(s string, strArray []string) []string

func Lstrip added in v1.3.0

func Lstrip(st string, substring string) string

Lstrip will return the string left striped with substring

func MapStructure added in v1.3.0

func MapStructure(m map[string]interface{}, i interface{}) error

MapStructure will map the map to the address of the structre *i

func Max added in v1.3.0

func Max(a int, b int) int

Min will return the minimize value

func MergeMaps added in v1.5.0

func MergeMaps(map1, map2 m) m

combine two strings maps to one, if key already exists - do nothing

func Min added in v1.3.0

func Min(a int, b int) int

Min will return the minimize value

func ModuleSourceAlignment added in v1.6.3

func ModuleSourceAlignment(manifestsFilePath string, source string, sourceLocal string, version string) error

func NeedFiltered added in v1.4.0

func NeedFiltered(filterList []string, key string) bool

NeedFiltered will return the attribute that should be filtered filterList should be array with regex like ["excluded\..+","excluded_[\s\S]+"]

func NegateBoolToString added in v1.3.0

func NegateBoolToString(value bool) string

NegateBoolToString reverts the boolean to its oppositely value as a string.

func NewRand added in v1.3.0

func NewRand() *rand.Rand

NewRand returns a rand with the time seed

func NewTuningConfigSpecProfileData added in v1.6.4

func NewTuningConfigSpecProfileData(vmDirtyRatio int) string

func Parse added in v1.3.0

func Parse(data []byte) map[string]interface{}

Parse parses the given JSON data and returns a map of strings containing the result.

func ParseProfiles added in v1.4.0

func ParseProfiles(profilesDir string) (map[string]*profile, error)

func ParseStringToMap added in v1.5.0

func ParseStringToMap(input string) (map[string]string, error)

func Pointer added in v1.6.3

func Pointer(f interface{}) *interface{}

func RHCSSourceAlignment added in v1.5.1

func RHCSSourceAlignment(manifestsFilePath string, rhcsSource string, rhcsVersion string) error

func RandomInt added in v1.6.3

func RandomInt(max int) int

func ReadFile added in v1.6.4

func ReadFile(absPath string) (string, error)

func ReplaceRegex added in v1.5.1

func ReplaceRegex(filePath string, regexP regexp.Regexp, replaceString string) error

func Rstrip added in v1.3.0

func Rstrip(st string, substring string) string

Rstrip will return the string right striped with substring

func RunCMD added in v1.3.0

func RunCMD(cmd string) (stdout string, stderr string, err error)

func ScanManifestsDir added in v1.5.1

func ScanManifestsDir(dir string) ([]string, error)

func StartsWith added in v1.3.0

func StartsWith(st string, substring string) (flag bool)

StartsWith return bool whether st start with substring

func StringMapPointer added in v1.6.3

func StringMapPointer(f map[string]string) *map[string]string

func StringPointer added in v1.5.1

func StringPointer(s string) *string

Return a string pointer of the input string value

func StringSlicePointer added in v1.6.3

func StringSlicePointer(f []string) *[]string

func Strip added in v1.3.0

func Strip(st string, substring string) string

Strip will return the value striped with substring

func Subfix added in v1.5.0

func Subfix(length int) string

Types

type IAMPolicy added in v1.6.3

type IAMPolicy struct {
	Version   string
	Statement []IAMPolicyStatement
}

func GetRoleAttachedPolicies added in v1.6.3

func GetRoleAttachedPolicies(roleName string) ([]IAMPolicy, error)

type IAMPolicyStatement added in v1.6.3

type IAMPolicyStatement struct {
	Effect   string
	Action   interface{}
	Resource interface{}
}

type TuningConfigSpecProfile added in v1.6.4

type TuningConfigSpecProfile struct {
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	Data string `yaml:"data,omitempty" json:"data,omitempty"`
}

type TuningConfigSpecRecommend added in v1.6.4

type TuningConfigSpecRecommend struct {
	Priority int    `yaml:"priority,omitempty" json:"priority,omitempty"`
	Profile  string `yaml:"profile,omitempty" json:"profile,omitempty"`
}

type TuningConfigSpecRoot added in v1.6.4

type TuningConfigSpecRoot struct {
	Profile   []TuningConfigSpecProfile   `json:"profile,omitempty" yaml:"profile,omitempty"`
	Recommend []TuningConfigSpecRecommend `json:"recommend,omitempty" yaml:"recommend,omitempty"`
}

func NewTuningConfigSpecRootStub added in v1.6.4

func NewTuningConfigSpecRootStub(tcName string, vmDirtyRatio int, priority int) TuningConfigSpecRoot

Jump to

Keyboard shortcuts

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