Documentation
¶
Overview ¶
Package utils contains various utilities
Index ¶
- Variables
- func AssetsFromTarGz(tmpDir, assetsBase string) error
- func AssetsToTarGz(assetsDir, gzipFile string) error
- func ByteToHr(b int64) string
- func CalcSize(path string) (int64, error)
- func CreateSSPak(sspakFile string, files []string) error
- func ExtractSSPak(sspakFile, outDir string) error
- func GzipFile(file, output string) error
- func HasEnoughSpace(location string, requiredSize int64) error
- func IsDir(path string) bool
- func IsFile(path string) bool
- func MkDirIfNotExists(path string) error
- func MySQLCreateDB(dropDatabase bool) error
- func MySQLDumpToGz(gzipFile string) error
- func MySQLLoadFromGz(gzipSQLFile string) error
- func TarGZCompress(inputFilePath, outputFilePath string) (err error)
- func TarGZExtract(inputFilePath, outputFilePath string) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( // DBDumpWrapper is a map of database dump to gzip functions based on DB.Type DBDumpWrapper = map[string]func(string) error{ "MySQL": MySQLDumpToGz, } // DBCreateWrapper is a map is database creation functions based on DB.Type DBCreateWrapper = map[string]func(bool) error{ "MySQL": MySQLCreateDB, } // DBLoadWrapper is a map of database load-from-gzip functions based on DB.Type DBLoadWrapper = map[string]func(string) error{ "MySQL": MySQLLoadFromGz, } )
The DB wrappers serve to map the various database functions to their respective types. This provides flexibility in the calling function without having to duplicate code and wrap in a whole bunch of if/else statements.
Functions ¶
func AssetsFromTarGz ¶
AssetsFromTarGz extracts assets from a tar.gz. If an existing assets directory is found then the existing one is renamed assets.old, and then deleted after the process completes.
func AssetsToTarGz ¶
AssetsToTarGz creates a tar.gz from the assets folder
func CreateSSPak ¶
CreateSSPak creates a regular POSIX tar file from a database and an assets archive
func ExtractSSPak ¶
ExtractSSPak extracts a SSPak (tar) file
func HasEnoughSpace ¶
HasEnoughSpace will return an error message if the provided location does not have sufficient storage space
func MkDirIfNotExists ¶
MkDirIfNotExists will create a directory if it doesn't exist
func MySQLCreateDB ¶
MySQLCreateDB a database, optionally dropping it
func MySQLDumpToGz ¶
MySQLDumpToGz uses mysqldump to stream a database dump directly into a gzip file
func MySQLLoadFromGz ¶
MySQLLoadFromGz loads a GZ database file into the database, streaming the gz file to the mysql cli.
func TarGZCompress ¶
TarGZCompress creates a archive from the folder inputFilePath. Only adds the last directory in inputFilePath to the archive, not the whole path. It tries to create the directory structure outputFilePath contains if it doesn't exist. It returns potential errors to be checked or nil if everything works.
func TarGZExtract ¶
TarGZExtract extracts a archive from the file inputFilePath. It tries to create the directory structure outputFilePath contains if it doesn't exist. It returns potential errors to be checked or nil if everything works.
Types ¶
This section is empty.