help

package
v0.0.0-...-445020f Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: Apache-2.0 Imports: 32 Imported by: 6

Documentation

Index

Constants

View Source
const (
	SshExtendedCommandTimeout = 300
	SshCommandTimeout         = 30
)

Timeouts

Variables

This section is empty.

Functions

func Abs

func Abs(path string) string

Returns an absolute path of the path

func AddPathSuffix

func AddPathSuffix(os, path string, suffixes ...string) string

AddPathSuffix joins path parts based on the OS

func AppendToFile

func AppendToFile(s, target string) error

Appends a string to the provided file

func CommandExitCode

func CommandExitCode(e error) (int, error)

Gets an exit code from the error

func CompareVersions

func CompareVersions(a, b string) int

func Copy

func Copy(src, dst string) error

Copy a file

func CopyDir

func CopyDir(src, dst string) error

Copy a directory recursively

func CreateDir

func CreateDir(path string) error

func CreateFile

func CreateFile(path string)

func DeleteDir

func DeleteDir(dir string) error

func DeleteFile

func DeleteFile(path string) error

func DeleteHost

func DeleteHost(fileName, host string) error

DeleteHost deletes host from ssh file or any other provided

func DirExists

func DirExists(path string) bool

DirExists returns whether the given file or directory exists or not

func DownloadFile

func DownloadFile(dst string, url string) (err error)

func DownloadFromUrl

func DownloadFromUrl(url, destination string) (string, error)

DownloadFromUrl downloads target file to destination folder create destination dir if does not exist download file if does not already exist shows progress bar

func DownloadFromUrlAsync

func DownloadFromUrlAsync(url, destination string, readBytesChannel chan int64, errorChan chan error) (string, int64, error)

DownloadFromUrl downloads target file to destination folder, creates destination dir if does not exist download file if does not already exist shows progress bar

func DownloadFromUrlWithAttempts

func DownloadFromUrlWithAttempts(url, destination string, retries int) (string, error)

Downloads From url with retries

func DownloadFromUrlWithAttemptsAsync

func DownloadFromUrlWithAttemptsAsync(url, destination string, retries int, wg *sync.WaitGroup) (string, *pb.ProgressBar, error)

Downloads from the url asynchronously

func DownloadQuiet

func DownloadQuiet(url, destination string) (string, error)

func DownloadQuietAttempts

func DownloadQuietAttempts(url, destination string, retries int) (string, error)

Downloads From url with retries

func EstablishConn

func EstablishConn(ip, user, passwd string) bool

Checks connection

func ExecCmd

func ExecCmd(cmdName string, cmdArgs []string) (string, error)

Executes command

func ExecStandardStd

func ExecStandardStd(name string, args ...string) error

ExecStandardStd executes standard command and all in and out channels are redirected to os (i.e. os.Stdout..)

func ExecSudo

func ExecSudo(cb sudo.PasswordCallback, cbData interface{}, script ...string) (string, error)

Executes commands via sudo

func Exists

func Exists(fullFileName string) bool

func ExitOnError

func ExitOnError(err error)

Exits with the code 1 in case of any error

func FileModeMask

func FileModeMask(name string, mask os.FileMode) (bool, error)

return true if the given file is writable/readable/executable using the given mask by an owner

func FileName

func FileName(path string) string

Gets a filename from the path

func GenericRunOverSsh

func GenericRunOverSsh(command, ip, user, password, port string, sudo bool, verbose bool, timeout int) (string, error)

Generic command run over ssh, which configures ssh detail and calls RunSshWithTimeout method

func GetArch

func GetArch() (string, error)

func GetBinPath

func GetBinPath() string

Returns a default bin path

func GetExtractCommand

func GetExtractCommand(file string) string

Returns extract command based on the filename

func GetFileLength

func GetFileLength(path string) (int64, error)

func GetFinalUrl

func GetFinalUrl(url string) (string, error)

func GetHTTPFileLength

func GetHTTPFileLength(url string) (int64, error)

func GetTempDir

func GetTempDir() string

GetTempDir returns OS specific tmp folder location without trailing slash

func GetZipFiles

func GetZipFiles(src string) ([]*zip.File, error)

GetZipFiles - gets the list of files inside zip archive

func HasAnySuffixes

func HasAnySuffixes(file string, suffix ...string) bool

HasAnySuffixes returns true if file contains any of the supplied suffixes

func HashFileMD5

func HashFileMD5(filePath string) (string, error)

HashFileMD5 returns md5 hash for a specified file

func LogCmdErrors

func LogCmdErrors(out, eut string, err error, args ...string)

func LogError

func LogError(err error)

Logs an error if any

func NewHttpProxyReader

func NewHttpProxyReader(r io.Reader, f func(n int, err error)) io.Reader

Create new proxy reader over bar Takes io.Reader or io.ReadCloser

func RunOverSsh

func RunOverSsh(command, ip, user, password string) (string, error)

Run ssh command

func RunSudoOverSsh

func RunSudoOverSsh(command, ip, user, password string, verbose bool) (string, error)

Run ssh echo password | sudo command

func RunSudoOverSshTimeout

func RunSudoOverSshTimeout(command, ip, user, password string, timeout int) (string, error)

Run ssh echo password | sudo command with timeout

func Scp

func Scp(src, dst, ip, user, password string) error

Scp file using 22 port

func ScpWPort

func ScpWPort(src, dst, ip, port, user, password string) error

Scp file

func Separator

func Separator() string

Separator returns the string separator

func Separators

func Separators(os string) string

Separators returns Os dependent separator

func StreamEasySsh

func StreamEasySsh(ip, user, password, port, key, command string, timeout int) (chan string, chan string, chan bool, error)

Stream easy ssh

func StringToSlice

func StringToSlice(a string, list []string) bool

func Unzip

func Unzip(src, dest string) error

Unzip into the destination folder

func UserHomeDir

func UserHomeDir() string

Gets homedir based on Os

func ValidURL

func ValidURL(str string) bool

ValidURL checks if the provided string is a valid URL

func WaitAndSpin

func WaitAndSpin(message string, progress chan bool)

Shows the message and rotates a spinner while `progress` is true and isn't closed

func WaitJobAndSpin

func WaitJobAndSpin(message string, job *BackgroundJob) (err error)

func WriteFile

func WriteFile(path string, content string)

func WriteToFile

func WriteToFile(s, target string) error

Writes a string to the provided file

Types

type BackgroundJob

type BackgroundJob struct {
	Progress chan bool
	Err      chan error
}

BackgroundJob contains 2 chans errors and progress indicating if task is in progress

func NewBackgroundJob

func NewBackgroundJob() *BackgroundJob

TODO should replace WaitAndSpin

func (*BackgroundJob) Active

func (b *BackgroundJob) Active(active bool)

func (*BackgroundJob) Close

func (b *BackgroundJob) Close()

func (*BackgroundJob) Error

func (b *BackgroundJob) Error(err error)

type HttpProxyReader

type HttpProxyReader struct {
	io.Reader
	// contains filtered or unexported fields
}

It's proxy reader, implement io.Reader

func (*HttpProxyReader) Close

func (self *HttpProxyReader) Close() (err error)

Close the reader when it implements io.Closer

func (*HttpProxyReader) Read

func (self *HttpProxyReader) Read(p []byte) (n int, err error)

type Iface

type Iface struct {
	Name         string
	HardwareAddr string
	Ipv4         string
}

Iface represents an entity with interfaceName hardware and ipv4

func GetIface

func GetIface() Iface

func LocalIfaces

func LocalIfaces() ([]Iface, error)

Get local interfaces with inited ip

type RuneDecimalReader

type RuneDecimalReader struct {
	RuneReader
}

func (*RuneDecimalReader) ReadRuneOrDecimal

func (v *RuneDecimalReader) ReadRuneOrDecimal() (val int32, size int, err error)

type RuneReader

type RuneReader interface {
	ReadRune() (rune, int, error)
	UnreadRune() error
}

Jump to

Keyboard shortcuts

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