Documentation
¶
Index ¶
- func ArrayContainsString(slice []string, element string) bool
- func AskForConfirmation() bool
- func CaptureStdOut() func() string
- func CaptureUserOut() func() string
- func CheckClose(c io.Closer)
- func CheckErr(err error)
- func Confirm(prompt string) bool
- func DownloadFile(fp string, url string, progressBar bool) (err error)
- func EnsureHTTPStatus(o *HTTPOptions) error
- func Error(format string, a ...interface{})
- func Failed(format string, a ...interface{})
- func FormatPlural(count int, single string, plural string) string
- func GetContainerUIDGid() (uid int, gid int, uidStr string, gidStr string)
- func GetGlobalDdevDir() string
- func GetInput(defaultValue string) string
- func IsCommandAvailable(cmdName string) bool
- func IsDockerToolbox() bool
- func IsPortActive(port string) bool
- func MapKeysToArray(mapWithKeys map[string]interface{}) []string
- func Prompt(prompt string, defaultValue string) string
- func RandString(n int) string
- func SetInputScanner(scanner *bufio.Scanner)
- func SetLetterBytes(lb string)
- func Success(format string, a ...interface{})
- func Warning(format string, a ...interface{})
- type HTTPOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayContainsString ¶ added in v1.4.0
ArrayContainsString returns true if slice contains element
func AskForConfirmation ¶
func AskForConfirmation() bool
AskForConfirmation requests a y/n from user.
func CaptureStdOut ¶ added in v1.4.0
func CaptureStdOut() func() string
CaptureStdOut captures Stdout to a string. Capturing starts when it is called. It returns an anonymous function that when called, will return a string containing the output during capture, and revert once again to the original value of os.StdOut.
func CaptureUserOut ¶ added in v1.4.0
func CaptureUserOut() func() string
CaptureUserOut captures output written to UserOut to a string. Capturing starts when it is called. It returns an anonymous function that when called, will return a string containing the output during capture, and revert once again to the original value of os.StdOut.
func CheckClose ¶
CheckClose is used to check the return from Close in a defer statement. From https://groups.google.com/d/msg/golang-nuts/-eo7navkp10/BY3ym_vMhRcJ
func CheckErr ¶
func CheckErr(err error)
CheckErr exits with a log.Fatal() if an error is encountered. It is normally used for errors that we never expect to happen, and don't have any normal handling technique. From https://davidnix.io/post/error-handling-in-go/
func Confirm ¶ added in v1.4.0
Confirm handles the asking and interpreting of a basic yes/no question. If DRUD_NONINTERACTIVE is set, Confirm() returns true. The prompt will be presented at most three times before returning false.
func DownloadFile ¶
DownloadFile retrieves a file.
func EnsureHTTPStatus ¶
func EnsureHTTPStatus(o *HTTPOptions) error
EnsureHTTPStatus will verify a URL responds with a given response code within the Timeout period (in seconds)
func Error ¶
func Error(format string, a ...interface{})
Error will print an red error message but will not exit.
func Failed ¶
func Failed(format string, a ...interface{})
Failed will print a red error message and exit with failure.
func FormatPlural ¶
FormatPlural is a simple wrapper which returns different strings based on the count value.
func GetContainerUIDGid ¶ added in v1.4.0
GetContainerUIDGid() returns the uid and gid (and string forms) to be used running most containers.
func GetGlobalDdevDir ¶
func GetGlobalDdevDir() string
GetGlobalDdevDir returns ~/.ddev, the global caching directory
func IsCommandAvailable ¶ added in v1.4.0
IsCommandAvailable uses shell's "command" to find out if a command is available https://siongui.github.io/2018/03/16/go-check-if-command-exists/ This lives here instead of in fileutil to avoid unecessary import cycles.
func IsDockerToolbox ¶ added in v1.4.0
func IsDockerToolbox() bool
IsDockerToolbox detects if the running docker is docker toolbox It shouldn't be run much as it requires actually running the executable. This lives here instead of in dockerutils to avoid unecessary import cycles. Inspired by https://stackoverflow.com/questions/43242218/how-can-a-script-distinguish-docker-toolbox-and-docker-for-windows
func IsPortActive ¶ added in v0.12.0
IsPortActive checks to see if the given port on docker IP is answering.
func MapKeysToArray ¶ added in v1.1.0
MapKeysToArray takes the keys of the map and turns them into a string array
func RandString ¶
RandString returns a random string of given length n.
func SetInputScanner ¶
SetInputScanner allows you to override the default input scanner with your own.
func SetLetterBytes ¶ added in v1.1.0
func SetLetterBytes(lb string)
SetLetterBytes exists solely so that tests can override the default characters used by RandString. It should probably be avoided for 'normal' operations. this is actually used in utils_test.go (test only) so we set nolint on it. nolint: deadcode
Types ¶
type HTTPOptions ¶
type HTTPOptions struct {
URL string
Username string
Password string
Timeout time.Duration
TickerInterval time.Duration
ExpectedStatus int
Headers map[string]string
}
HTTPOptions defines the URL and other common HTTP options for EnsureHTTPStatus.
func NewHTTPOptions ¶
func NewHTTPOptions(URL string) *HTTPOptions
NewHTTPOptions returns a new HTTPOptions struct with some sane defaults.