Documentation ¶
Index ¶
- func CompareFileHash(sourcePath, expectedHash string) (bool, error)
- func Copy(srcPath, destPath string) (err error)
- func Download(url, downloadDir string, perms os.FileMode) (downloadedFileName string, err error)
- func FilterDirectories(_ string, info os.FileInfo) bool
- func Glob(pattern, realm string, matcher gitignore.Matcher, filters ...FilterFunc) (matches []string, err error)
- func GzipTar(srcDir string, dest io.Writer) error
- func GzipTarFiles(files []string, prefix string, dest io.Writer, injector TarInjectorFunc) error
- func GzipUntar(extractDir string, r io.Reader) error
- func HashDir(dir string, rootHash hash.Hash) (hash.Hash, error)
- func HashFile(file string, rootHash hash.Hash) (hash.Hash, error)
- func NormalizePath(baseDir, path string) (string, error)
- func NormalizePathByPrefix(file, absBase, relBase string) (cleanFile string, err error)
- func ReadFileBytes(filename string) ([]byte, error)
- func ReadFileJSON(filename string, v interface{}) error
- func ReadFileString(filename string) (string, error)
- func SortedFiles(dir string) ([]string, error)
- func Split(path string) []string
- func TrimPrefix(file string, prefix string) string
- func TrimPrefixAll(files []string, prefix string) []string
- type File
- type FilterFunc
- type TarFile
- type TarInjectorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareFileHash ¶
CompareFileHash calculates a hash for a file and compares it against an expected hash
func FilterDirectories ¶
FilterDirectories ignores directories in the file walk
func Glob ¶
func Glob(pattern, realm string, matcher gitignore.Matcher, filters ...FilterFunc) (matches []string, err error)
Glob adds double-star support to the core path/filepath Glob function. It's useful when your globs might have double-stars, but you're not sure. You might recognize "**" recursive globs from things like your .gitignore file, and zsh. The "**" glob represents a recursive wildcard matching zero-or-more directory levels deep.
func GzipTarFiles ¶
GzipTarFiles takes an explicit list of files and generates a gzipped tar archive to the dest io.Writer If a prefix is supplied it will trim that prefix from the file names before writing to the archive
func HashDir ¶
HashDir calculates the root hash of all files in a given directory (defaults to sha256 hash)
func HashFile ¶
HashFile calculates the sha256 of the given files contents (defaults to sha256 hash)
func NormalizePath ¶
NormalizePath expands a non absolute path by resolving home directory and ensure that the path is canonical for the host OS
func NormalizePathByPrefix ¶
NormalizePathByPrefix normalizes files with relative or absolute prefixes / will be considered absolute ./ will be normalized to the relBase // will be normalized to the relBase otherwise they will be normalized to absBase
func ReadFileBytes ¶
ReadFileBytes an alias to ioutil.ReadFIle
func ReadFileJSON ¶
ReadFileJSON reads a file and unmarshalls the data into the given interface
func ReadFileString ¶
ReadFileString reads a files contents as a string
func SortedFiles ¶
SortedFiles aggregates all files under a specified directory and sorts lexically sorts them
func TrimPrefix ¶
TrimPrefix trims the given prefix off a filename
func TrimPrefixAll ¶
TrimPrefixAll returns a sorted list of filenames with their prefix trimmed from the supplied list
Types ¶
type File ¶
type File struct { Name string Exists bool New bool Type string Hash string SymlinkTarget string RelName string }
File a basic interface representing a file on disk
func NativeFileToSynthetic ¶
NativeFileToSynthetic accepts a path to a file and a os.FileInfo interface and provides a pointer to an fs.File This function can return errors when attempting to resolve a symlink location and when attempting to compute the file contents current hash
type FilterFunc ¶
FilterFunc should return true if a file should be retained
func FilterBySuffix ¶
func FilterBySuffix(suffix string) FilterFunc
FilterBySuffix ignores files with the provided suffix
type TarInjectorFunc ¶
TarInjectorFunc is a function used to intercept and write last minute files to a tar file
func InjectTarFiles ¶
func InjectTarFiles(files []*TarFile) TarInjectorFunc
InjectTarFiles injects in memory files into a tar writer