util

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiEnvVar = "API_URL"
View Source
var DEFAULT_API_BASE_URL = "https://api.whiteblock.io"

Functions

func CheckAndConvertInt

func CheckAndConvertInt(num string, name string) int

func CheckAndConvertInt64

func CheckAndConvertInt64(num string, name string) int64

func CheckArguments

func CheckArguments(cmd *cobra.Command, args []string, min int, max int)

func CheckIntegerBounds

func CheckIntegerBounds(cmd *cobra.Command, name string, val int, min int, max int)

func ClientNotSupported

func ClientNotSupported(client string)

func CreateAuthNHeader added in v1.7.1

func CreateAuthNHeader() (string, error)

func DeleteStore

func DeleteStore(name string) error

func GetEnvVar added in v1.7.7

func GetEnvVar(envVar, fallback string) string

Get API_BASE_URL from the environment variable API_URL or fallback to the default

func HttpRequest

func HttpRequest(method string, url string, bodyData string) ([]byte, error)

Sends an http request and returns the body. Gives an error if the http request failed or returned a non success code.

func InvalidArgument

func InvalidArgument(arg string)

func InvalidInteger

func InvalidInteger(name string, value string, fatal bool)

func JwtHTTPRequest added in v1.7.1

func JwtHTTPRequest(method string, url string, bodyData string) (string, error)

JwtHTTPRequest is similar to HttpRequest, but it have the content-type set as application/json and it will put the given jwt in the auth header

func PartialCommand

func PartialCommand(cmd *cobra.Command, args []string)

func PrintError

func PrintError(err error)

func PrintErrorFatal

func PrintErrorFatal(err error)

func PrintStringError

func PrintStringError(err string)

func ReadStore

func ReadStore(name string) ([]byte, error)

func StoreExists

func StoreExists(name string) bool

func UnrollStringSliceToMapIntString added in v1.6.3

func UnrollStringSliceToMapIntString(slices []string, delim string) (map[int]string, []string, error)

func UnrollStringSliceToMapStringString added in v1.6.3

func UnrollStringSliceToMapStringString(slices []string, delim string) (map[string]string, error)

func Write

func Write(path string, data []byte) error

Write writes data to a file, creating it if it doesn't exist, deleting and recreating it if it does.

func WriteStore

func WriteStore(name string, data []byte) error

func YesNoPrompt

func YesNoPrompt(msg string) bool

Types

type SshClient

type SshClient struct {
	// contains filtered or unexported fields
}

func NewSshClient

func NewSshClient(host string) (*SshClient, error)

func (SshClient) Close

func (this SshClient) Close()

func (SshClient) DockerExec

func (this SshClient) DockerExec(node int, command string) (string, error)

func (SshClient) DockerExecd

func (this SshClient) DockerExecd(node int, command string) (string, error)

func (SshClient) DockerMultiExec

func (this SshClient) DockerMultiExec(node int, commands []string) (string, error)

func (SshClient) DockerRead

func (this SshClient) DockerRead(node int, file string) (string, error)

func (SshClient) FastMultiRun

func (this SshClient) FastMultiRun(commands ...string) (string, error)

*

  • Speeds up remote execution by chaining commands together
  • @param ...string commands The commands to execute
  • @return string The result of the execution

func (SshClient) GetSession

func (this SshClient) GetSession() (*ssh.Session, error)

func (SshClient) MultiRun

func (this SshClient) MultiRun(commands ...string) ([]string, error)

*

  • Easy shorthand for multiple calls to sshExec
  • @param ...string commands The commands to execute
  • @return []string The results of the execution of each command

func (SshClient) Run

func (this SshClient) Run(command string) (string, error)

func (SshClient) Scp

func (this SshClient) Scp(src string, dest string) error

*

  • Copy a file over to a remote machine
  • @param string host The IP address of the remote host
  • @param string src The source path of the file
  • @param string dest The destination path of the file

Jump to

Keyboard shortcuts

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