util

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Fs is the global file system instance, can be backed by real FS or MemMapFs for testing.

Functions

func AppendToFile

func AppendToFile(filePath, content string) error

AppendToFile appends content to a file

func ChangeFileOwnership

func ChangeFileOwnership(filePath string, user *user.User) error

ChangeFileOwnership changes the ownership of a file

func CreateDirAndChown

func CreateDirAndChown(dirPath string, perm os.FileMode, user *user.User) error

CreateDirAndChown creates a directory and changes its ownership

func FileExists

func FileExists(filePath string) bool

FileExists checks if a file exists or not

func GetRepoNameFromConfig

func GetRepoNameFromConfig(path string) (string, error)

GetRepoNameFromConfig checks if the current directory (or any of its parent directories) is inside a Git repository. If inside a Git repo, it retrieves and returns the repository name.

func IsScriptPresent

func IsScriptPresent(filePath, script string) bool

IsScriptPresent checks if a script is already present in a file

func SetupFS

func SetupFS()

SetupFS initialize the file system instance. When used in testing, the Fs variable is swapped out to afero.MemMapFs.

func WriteFileAndChown

func WriteFileAndChown(filePath string, content []byte, perm os.FileMode, user *user.User) error

WriteFileAndChown writes content to a file and changes its ownership

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL