utils

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: Apache-2.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(url, path string) error

func EcsdaPrivateKey

func EcsdaPrivateKey()

func EcsdaPublicKey

func EcsdaPublicKey()

func EnsureSSHDir added in v0.9.9

func EnsureSSHDir() error

func EnvVarName

func EnvVarName()

func Exec

func Exec(sh string, args ...interface{}) error

Exec runs the sh script and forwards stderr/stdout to the console

func ExecNoOutput added in v0.9.9

func ExecNoOutput(sh string, args ...interface{}) error

Exec runs the sh script and forwards stderr/stdout to the console

func FileCopy

func FileCopy(src string, dst string) error

func FileExists

func FileExists(path string) bool

func GET

func GET(url string, args ...interface{}) ([]byte, error)

func GenerateSSHKeys added in v0.9.9

func GenerateSSHKeys(prefix string) (string, string, error)

func GetBaseName

func GetBaseName(filename string) string

func GetEnvOrDefault

func GetEnvOrDefault(names ...string) string

func Greenf

func Greenf(msg string, args ...interface{}) string

func GzipFile

func GzipFile(path string) ([]byte, error)

GzipFile takes the path to a file and returns a Gzip comppressed byte slic

func IniToMap

func IniToMap(path string) map[string]string

IniToMap takes the path to an INI formatted file and transforms it into a map

func Interpolate

func Interpolate(arg string, vars interface{}) string

func InterpolateStrings

func InterpolateStrings(arg []string, vars interface{}) []string

func IsSlice

func IsSlice(arg interface{}) bool

IsSlice returns true if the argument is a slice

func IsTTY

func IsTTY() bool

func LightCyanf

func LightCyanf(msg string, args ...interface{}) string

func LightGreenf

func LightGreenf(msg string, args ...interface{}) string

func LookupFile

func LookupFile()

func MapToIni

func MapToIni(Map map[string]string) string

MapToIni takes a map and converts it into an INI formatted string

func PrivateKey

func PrivateKey()

func PublicKey

func PublicKey()

func RandomString

func RandomString(length int) string

RandString returns a random string consisting of the characters in randomChars, with the length customized by the parameter

func Redf

func Redf(msg string, args ...interface{}) string

func ReplaceAllInSlice

func ReplaceAllInSlice(a []string, find string, replacement string) (replaced []string)

ReplaceAllInSlice runs strings.Replace on all elements in a slice and returns the result

func RsaPrivateKey

func RsaPrivateKey()

func RsaPublicKey

func RsaPublicKey()

func RunSSHCommand added in v0.9.9

func RunSSHCommand(host, user, privateKeyFile, cmd string) ([]byte, error)

func RunSSHScript added in v0.9.9

func RunSSHScript(host, user, privateKeyFile, script string) ([]byte, error)

func SSHKey

func SSHKey()

func SafeExec

func SafeExec(sh string, args ...interface{}) (string, bool)

SafeExec executes the sh script and returns the stdout and stderr, errors will result in a nil return only.

func SafeRead

func SafeRead(path string) string

SafeRead reads a path and returns the text contents or nil,

func ShortTimestamp

func ShortTimestamp() string

ShortTimestamp returns a shortened timestamp using week of year + day of week to represent a day of the e.g. 1st of Jan on a Tuesday is 13

func SplitAllInSlice

func SplitAllInSlice(a []string, split string, index int) (replaced []string)

SplitAllInSlice runs strings.Split on all elements in a slice and returns the results at the given index

func StructToIni

func StructToIni(s interface{}) string

StructToIni takes an object and serializes it's fields in INI format

func StructToMap

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

StructToMap takes an object and returns all it's field in a map

func ToGenericMap

func ToGenericMap(m map[string]string) map[string]interface{}

func ToString

func ToString(i interface{}) string

ToString takes an object and tries to convert it to a string

func ToStringMap

func ToStringMap(m map[string]interface{}) map[string]string

func X509Cert

func X509Cert()

Types

This section is empty.

Jump to

Keyboard shortcuts

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