Documentation ¶
Index ¶
- func CopyFileContents(src string, dst string, permission os.FileMode) error
- func FileContentMatches(path string, expectedContent []byte) error
- func FileExists(path string) bool
- func RemoveFileAsRoot(reason, filepath string) error
- func RemoveFileIfExists(path string) error
- func ReplaceOrAddEnv(variables []string, varName string, value string) []string
- func RunPrivileged(reason string, cmdAndArgs ...string) (string, string, error)
- func RunWithDefaultLocale(command string, args ...string) (string, string, error)
- func RunWithDefaultLocalePrivate(command string, args ...string) (string, string, error)
- func RunningInTerminal() bool
- func WriteFileIfContentChanged(path string, newContent []byte, perm os.FileMode) (bool, error)
- func WriteToFileAsRoot(reason, content, filepath string, mode os.FileMode) error
- type CommandRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileContentMatches ¶ added in v1.20.0
func FileExists ¶
FileExists returns true if the file at path exists. It returns false if it does not exist, or if there was an error when checking for its existence. This means there can be false negatives if Lstat fails because of permission issues (file exists, but is not reachable by the current user)
func RemoveFileAsRoot ¶
func RemoveFileIfExists ¶ added in v1.23.0
func ReplaceOrAddEnv ¶ added in v1.14.0
ReplaceOrAddEnv changes the value of an environment variable if it exists otherwise add the new variable It drops the existing value and appends the new value in-place
func RunPrivileged ¶ added in v1.23.0
RunPrivileged executes a command using sudo provide a reason why root is needed as the first argument
func RunWithDefaultLocale ¶
func RunningInTerminal ¶ added in v1.23.0
func RunningInTerminal() bool
Types ¶
type CommandRunner ¶ added in v1.16.0
type CommandRunner interface { Run(command string, args ...string) (string, string, error) RunPrivate(command string, args ...string) (string, string, error) RunPrivileged(reason string, cmdAndArgs ...string) (string, string, error) }
func NewLocalCommandRunner ¶ added in v1.16.0
func NewLocalCommandRunner() CommandRunner
Click to show internal directories.
Click to hide internal directories.