Documentation ¶
Index ¶
- Variables
- func AppendToFileOrCreateDirAndWriteToFile(bytes []byte, file string, perms ...os.FileMode) error
- func AskForConfirmation(msg string) bool
- func BoolPtr(b bool) *bool
- func CheckFileExistsAndRecreate(file string) bool
- func CheckRegexInFile(regex, filePath string) (bool, error)
- func CheckRegexInString(regex, str string) bool
- func CommandAvailable(name string) bool
- func ContainsString(slice []string, vals ...string) bool
- func ConvertVersionPrereleaseToMetadata(v *version.Version) *version.Version
- func CreateDir(dir string, perm *os.FileMode) error
- func CreateDirAndWriteToFile(bytes []byte, file string, perms ...os.FileMode) error
- func DecompressFileFromArchive(src io.Reader, archive, filename string) (io.Reader, error)
- func DockerHost() string
- func EvalSymlinkPath(file string) (string, error)
- func ExtractUnknownArgs(flags *pflag.FlagSet, args []string) []string
- func FileExists(file string) bool
- func HomeDir() string
- func Insert(array []string, index int, value string) []string
- func InsertStringAfterOccurrence(args []string, insertStr, searchStr string) []string
- func InsertStringBeforeOccurrence(args []string, insertStr, searchStr string) []string
- func IsAdmin() bool
- func OSDistro() string
- func Quote(s string) string
- func RemoveStringFromSlice(s []string, r string) []string
- func RunMeElevated()
- func Unzip(src io.Reader, dest string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFileWithThisDirNameExist occurs when file already exist. ErrFileWithThisDirNameExist = errors.New("file with the same name exists") // ErrFileNotFound occurs when file is not found. ErrFileNotFound = func(s string) error { return errors.Errorf("file not found: %s", s) } )
var FS = &afero.Afero{Fs: afero.NewOsFs()}
FS is the implementation of Afero Filesystem. It's a filesystem wrapper and used for testing.
Functions ¶
func AppendToFileOrCreateDirAndWriteToFile ¶
AppendToFileOrCreateDirAndWriteToFile creates the base directory and writes to a file in it. Perms are optional. The first permission will be the file permission, the second will be the directory permission.
func AskForConfirmation ¶
AskForConfirmation ask msg from the user and returns the answer.
func CheckFileExistsAndRecreate ¶
CheckFileExistsAndRecreate checks if the file already exists and ask the user if he'd like to recreate it. If user input is yes - return false (as if the file does not existing).
func CheckRegexInFile ¶
CheckRegexInFile checks if the file contains content.
func CheckRegexInString ¶
CheckRegexInString checks if the string contains content.
func CommandAvailable ¶
CommandAvailable returns if the parameter can be find in $PATH.
func ContainsString ¶
ContainsString checks if a slice of string contains a string.
func ConvertVersionPrereleaseToMetadata ¶ added in v0.6.14
func ConvertVersionPrereleaseToMetadata(v *version.Version) *version.Version
func CreateDirAndWriteToFile ¶
CreateDirAndWriteToFile creates the base directory and writes bytes to a file in it. Perms are optional. The first permission will be the file permission, the second will be the directory permission.
func DockerHost ¶
func DockerHost() string
func EvalSymlinkPath ¶
EvalSymlinkPath checks if file exists and returns the resolved path if a symlink if file is a symlink, else it returns the filepath.
func ExtractUnknownArgs ¶
ExtractUnknownArgs returns []string arguments which are not used by pflags.
func FileExists ¶
FileExists checks if the file already exists and ask the user if he'd like to recreate it.
func InsertStringAfterOccurrence ¶
InsertStringAfterOccurrence inserts insertStr after the occurrence of searchStr to args and returns args. If searchStr does not exist it will append to the end of args.
func InsertStringBeforeOccurrence ¶
InsertStringBeforeOccurrence inserts insertStr before occurrence of searchStr (if exist) to args and returns args. If searchStr doesn't exist it will append to the end of args.
func OSDistro ¶
func OSDistro() string
OSDistro returns the linux distro name if GOOS is linux, else "darwin" or "windows".
func Quote ¶
Quote puts a quote around s string in Unix-like systems and returns it, while it just returns s as-is on Windows.
func RemoveStringFromSlice ¶
Types ¶
This section is empty.