util

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSearchHostMaps

func AppendSearchHostMaps(searchhostmaps []map[string]string, hostmap map[string]string) []map[string]string

AppendSearchHostMaps append not exist elements

func ArgFilterToMap

func ArgFilterToMap(argfilter string) (map[string]string, error)

ArgFilterToMap arguments filter to map[string]string

func ByteToHosts

func ByteToHosts(bytes []byte) ([]cli.Host, error)

ByteToHosts parse byte to host

func CheckAddress

func CheckAddress(address string) (string, error)

CheckAddress validata ssh address

func CheckArrayContainsSubstr

func CheckArrayContainsSubstr(elements []string, substr string) bool

CheckArrayContainsSubstr

func CheckPassword

func CheckPassword(password string) (string, error)

CheckPassword validata ssh password

func CheckPortRange

func CheckPortRange(port string) (int32, error)

CheckPortRange validata ssh port

func CheckPublicKey

func CheckPublicKey(key string) (string, error)

CheckPublicKey validata ssh publicKey

func CheckUsername

func CheckUsername(username string) (string, error)

CheckUsername validata ssh username

func Clear

func Clear()

clear clear the terminal screen

func Cmd

func Cmd(name string, arg ...string)

cmd call system command

func CreateDataPathJsonFile

func CreateDataPathJsonFile(addhosts ...cli.Host) error

CreateDataPathJsonFile create `$KUSH_HOME/.kush/.kush.json` by host

func CurrentUser

func CurrentUser() (string, error)

CurrentUser return current execute user

func CurrentUserHome

func CurrentUserHome() (string, error)

CurrentUserHome return `user.HomeDir`

func DirectArrayToMap

func DirectArrayToMap(elements []string) (map[string]string, error)

DirectArrayToMap

func DirectStringToMap

func DirectStringToMap(argString string) (map[string]string, error)

DirectStringToMap

func ExitPrintln

func ExitPrintln(printText any)

ExitPrintln terminal console output

func ExportDataPathFile

func ExportDataPathFile(output string, outhosts ...map[string]string) error

ExportDataPathFile export host to file stream

func GetDataPathRootHome

func GetDataPathRootHome() (string, error)

GetDataPathRootHome get current user home path or $KUSH_HOME value to assign data path home

func GetEnv

func GetEnv(key, fallback string) string

GetEnv get environment variable value

func GetKushJson

func GetKushJson() (string, error)

GetKushJson return .kush.json absolute path

func HostEquals

func HostEquals(source cli.Host, target cli.Host) bool

HostEquals compare two hosts for equality

func HostMapsByValueSpace

func HostMapsByValueSpace(searchhostmaps []map[string]string, columns []string) map[string]int

HostMapsByValueSpace calculate the maximum length of the value of the specified key in the set

func HostMapsFilter

func HostMapsFilter(filtermap map[string]string, diskhosts []cli.Host) ([]map[string]string, error)

HostMapsFilter filter host map collections

func HostMapsReturnColumns

func HostMapsReturnColumns(searchhostmaps []map[string]string, columns ...string) ([]map[string]string, error)

HostMapsReturnColumns search collections show required columns

func HostMapsSort

func HostMapsSort(searchhostmaps []map[string]string, sortfield string) ([]map[string]string, error)

HostMapsSort sort host map collections

func HostToMap

func HostToMap(host cli.Host) (map[string]string, error)

HostToMap struct to map

func ImportDataPathFile

func ImportDataPathFile(inputbytes []byte, output string) error

func InArray

func InArray(target string, arrays []string) bool

InArray check if an element is in an array

func ManyIsEmpty

func ManyIsEmpty(elements ...string) error

ManyIsEmpty multi element is empty check

func ManyIsNotEmpty

func ManyIsNotEmpty(elements ...string) error

ManyIsNotEmpty multi element is not empty check

func MapValueToString

func MapValueToString(arrayMaps map[string]string, sep string) string

MapValueToString the map value is converted into a string and join using sep

map[string]string { "key1":"value1", "key2":"value2" } => return "value1,value2"

func PasswordWarning

func PasswordWarning()

func ReadFileToBytes

func ReadFileToBytes(file string) ([]byte, error)

ReadFileToByte parse file to bytes

func Remove

func Remove[T any](slice []T, s int) []T

Remove remove any slice array by index

func RemoveDataPathJsonFile

func RemoveDataPathJsonFile(delhosts ...cli.Host) error

RemoveDataPathJsonFile remove `$KUSH_HOME/.kush/.kush.json` by host

func RenderTable

func RenderTable(searchhostmaps []map[string]string, columns ...string)

RenderTable render the table

func RenderTableHead

func RenderTableHead(valuespaces map[string]int, columns ...string) (map[string]int, string)

RenderTableHead render the table header and return the size of each column in the header

func RenderTableRow

func RenderTableRow(searchhostmaps []map[string]string, headspaces map[string]int, columns ...string) string

RenderTableRow render the table row

func SearchHostToTerminal

func SearchHostToTerminal(searchhostmap map[string]string) (*cli.Terminal, error)

SearchHostToTerminal search host to terminal struct

func StringArrayToMap

func StringArrayToMap(elements []string) (map[string]string, error)

StringArrayToMap convert array to map type

func StringArrayToString

func StringArrayToString(elements []string) string

StringArrayToString arrry to string eg:[A B C] =>A,B,C

func StringToMap

func StringToMap(argString string) (map[string]string, error)

StringToMap convert string to map type

func UpdateDataPathJsonFile

func UpdateDataPathJsonFile(updatehosts []cli.Host) error

UpdateDataPathJsonFile update `$KUSH_HOME/.kush/.kush.json` by host

func UpperCaseFirstLetter

func UpperCaseFirstLetter(word string) (string, error)

UpperCaseFirstLetter return after convert word first letter to upper case

eg: word->Word , WORD->Word

func WriteFileToBytes

func WriteFileToBytes(file string, data []byte) error

WriteFileToBytes bytes to file

Types

This section is empty.

Jump to

Keyboard shortcuts

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