utils

package
v0.14.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bash

func Bash(cmd string) (string, error)

Bash executes a shell command and returns its standard output as a string

func BashWithArgs added in v0.6.0

func BashWithArgs(cmd string, args ...string) (string, error)

BashWithArgs executes a shell command with arguments and returns its standard output

func ConvertNodeName

func ConvertNodeName(node string) string

ConvertNodeName e.g.(10.23.10.12 => 10-23-10-12)

func ConvertShellOutputs

func ConvertShellOutputs(outputs string) []string

ConvertShellOutputs splits shell output string into a slice of strings, one per line

func ExecCmd added in v0.6.0

func ExecCmd(command, args string) (out []byte, err error)

ExecCmd executes a shell command with arguments as a single string and returns its output

func FoundNewStringElems added in v0.6.0

func FoundNewStringElems(old, new []string) ([]string, bool)

FoundNewStringElems compare two arrays, find if there is new elem in new array

func FuncName

func FuncName() string

func GetAllIndex

func GetAllIndex(s string, substr string) []int

GetAllIndex returns all indices of the substr in the given string

func GetNamespace

func GetNamespace() string

GetNamespace get Namespace from env, else it returns error

func GetNodeName

func GetNodeName() string

GetNodeName gets the node name from env, else returns an error

func Hash

func Hash(str string) string

Hash returns the MD5 hash of a string

func ParseKeyValuePairString

func ParseKeyValuePairString(propsRaw string) map[string]string

converts a raw key value pair string into a map of key value pairs example raw string of `foo="0" bar="1" baz="biz"` is returned as: map[string]string{"foo":"0", "bar":"1", "baz":"biz"}

func ReadSysFSFileAsInt64

func ReadSysFSFileAsInt64(sysFilePath string) (int64, error)

ReadSysFSFileAsInt64 reads a file from the sysfs filesystem and converts its content to int64. Suitable for numeric information such as device size, etc.

func ReadSysFSFileAsString

func ReadSysFSFileAsString(sysFilePath string) (string, error)

ReadSysFSFileAsString reads a file from the sysfs filesystem and returns its content as a string. Suitable for text information such as device state, wwid, etc.

func StrFind

func StrFind(slice []string, val string) (int, bool)

func StructToMap

func StructToMap(in interface{}, tagName string) map[string]interface{}

Types

type ByDiskSize added in v0.10.0

type ByDiskSize []types.Disk

ByDiskSize makes an array of disks sortable by their size in descending order.

func (ByDiskSize) Len added in v0.10.0

func (a ByDiskSize) Len() int

func (ByDiskSize) Less added in v0.10.0

func (a ByDiskSize) Less(i, j int) bool

func (ByDiskSize) Swap added in v0.10.0

func (a ByDiskSize) Swap(i, j int)

type ByVolumeCapacity added in v0.10.0

type ByVolumeCapacity []*corev1.PersistentVolumeClaim

ByVolumeCapacity makes an array of pvcs sortable by their storage capacity in descending order.

func (ByVolumeCapacity) Len added in v0.10.0

func (a ByVolumeCapacity) Len() int

func (ByVolumeCapacity) Less added in v0.10.0

func (a ByVolumeCapacity) Less(i, j int) bool

func (ByVolumeCapacity) Swap added in v0.10.0

func (a ByVolumeCapacity) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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