Documentation ¶
Index ¶
- Constants
- func BurnAfterReading(file *os.File)
- func DownloadFile(url string) (destFile *os.File, finalErr error)
- func IsValidEmailAddress(email string) bool
- func LogError(action func() error)
- func LogNonNilError(err error)
- func MergeErrors(message string, newError error, previousError error) error
- func PanicOnError(action func() error)
- func PanicOnNonNilErr(err error)
- func ReadAllIntoTempFile(src io.Reader, pattern string) (file *os.File, err error)
- func ReopenFile(file *os.File) (*os.File, error)
- func SyncAndCloseFunc(file *os.File, topError *error)
- func TryExtractFirstLastNameAndEmail(contents string) (firstName string, lastName string, emailAddress string)
Constants ¶
const ( // DefaultTimeout default timeout for most operations DefaultTimeout = 10 * time.Minute // DownloadTimeout is the configured download timeout after which the run is aborted DownloadTimeout = 30 * time.Minute // PortAvailableTimeout timeout used while waiting for a port to become available PortAvailableTimeout = 30 * time.Minute // LongCreationTimeout timeout to use for longer operations LongCreationTimeout = 60 * time.Minute // ServiceStartedTimeout timeout used while waiting for a service to be started ServiceStartedTimeout = 1 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func BurnAfterReading ¶
BurnAfterReading ensure a consumed file is closed and deleted
func DownloadFile ¶
DownloadFile downloads the specified url to a temporary location
func IsValidEmailAddress ¶
IsValidEmailAddress returns true if the passed string is a valid email address
func MergeErrors ¶
MergeErrors constructs a new error based on a description string, given error, and a potentially previously existing error TODO(mihaibojin): https://godoc.org/gopkg.in/errgo.v2/fmt/errors
func PanicOnError ¶
func PanicOnError(action func() error)
PanicOnError panics when the action is run and results in an error
func PanicOnNonNilErr ¶
func PanicOnNonNilErr(err error)
PanicOnNonNilErr convenience wrapper which panics when the passed error is not nil
func ReadAllIntoTempFile ¶
ReadAllIntoTempFile reads all available data and saves it into a temporary file, using the specified pattern to identify it on the file system returns a file ready for reading
func ReopenFile ¶
ReopenFile reopens the file specified by the passed file descriptor, for reading
func SyncAndCloseFunc ¶
SyncAndCloseFunc returns a function which can be passed to defer to sync and close the file, thus ensuring all data was saved on disk, or outlining any problems with the underlying file-system this implementation is loosely based on https://www.joeshaw.org/dont-defer-close-on-writable-files/ and https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md
func TryExtractFirstLastNameAndEmail ¶
func TryExtractFirstLastNameAndEmail(contents string) (firstName string, lastName string, emailAddress string)
TryExtractFirstLastNameAndEmail attempts to extract first, last name and email address
- if the passed contents are not an email, both the first/last names will be set to the specified value and the email will be left blank
if the email address does not contain a separator character, its user part will be set to both first/last name values if the email address has a dot or underscore separator character, the first name will be set to
the string up to the separator and the last name will be set to the character string starting after the separator
Types ¶
This section is empty.