Documentation ¶
Index ¶
- Variables
- func EnsureDirectory(dir string) error
- func FindInInterface(iface interface{}, mapKeys ...string) (interface{}, error)
- func GetShell() (string, error)
- func HostCommandExists(cmd string) (bool, error)
- func InterfaceToJSON(mapVar interface{}) ([]byte, error)
- func IsInRange(target, since, until time.Time) bool
- func JSONToFile(JSON []byte, outFile string) error
- func SplitFilepath(path string) (dir string, file string)
- func TarGz(sourceDir string, destFileName string, baseName string) error
- func WriteJSON(iface interface{}, filePath string) error
- type CommandNotFoundError
Constants ¶
This section is empty.
Variables ¶
var ErrNoShellOnWindows = errors.New("shell{} is not supported on Windows. please use command{}")
ErrNoShellOnWindows occurs when GetShell() is run on a Windows machine.
var ErrUnknownShell = errors.New("unable to determine shell from environment. please set the $SHELL environment variable")
ErrUnknownShell occurs when the $SHELL environment variable is empty or not set.
Functions ¶
func EnsureDirectory ¶ added in v0.3.1
EnsureDirectory will ensure that the full path to the destination directory exists. If the full path exists, this is a no-op and will return nil. Otherwise, it will create any directories that do not exist in the destination path. Any directories created will be given file permissions 0755.
func FindInInterface ¶
FindInInterface treats an interface{} like a (nested) map, and searches through its contents for a given list of mapKeys. For example, given an interface{} containing a map like iface ~ interface{}{"top": {"mid": {"bottom": "desired_value"}}} one could fetch an interface{} of "desired_value" with FindInInterface(iface, "top", "mid", "bottom") then afterwards cast it to a string, or whatever type you're expecting.
func GetShell ¶
GetShell returns the value of the $SHELL environment variable, or an error if on Windows or the variable is not set.
func HostCommandExists ¶ added in v0.5.0
HostCommandExists takes a single OS-level command name, returning true if it exists in $PATH; false/CommandNotFoundError otherwise
func InterfaceToJSON ¶
InterfaceToJSON converts an interface{} to JSON.
func JSONToFile ¶
JSONToFile accepts JSON and an output file path to create a JSON file.
func SplitFilepath ¶
SplitFilepath takes a full path string and turns it into directory and file parts. In particular, it's useful for passing into runner.NewCopy()
func TarGz ¶
TarGz is a utility function for archiving and compressing files. Its arguments include the source directory that you wish to archive; a destination filename, which is the .tar.gz file you want to create; and a baseName, which is the name of the directory that should be created when the resulting .tar.gz file is later extracted.
Types ¶
type CommandNotFoundError ¶ added in v0.5.0
type CommandNotFoundError struct {
// contains filtered or unexported fields
}
func (CommandNotFoundError) Error ¶ added in v0.5.0
func (e CommandNotFoundError) Error() string
func (CommandNotFoundError) Unwrap ¶ added in v0.5.0
func (e CommandNotFoundError) Unwrap() error