Documentation ¶
Index ¶
- Variables
- func AreFilesEuqalMust(path1, path2 string) bool
- func Assert(ok bool, format string, args ...interface{})
- func CdUpDir(dirName string)
- func CloseNoError(f io.Closer)
- func CopyAndExecServerScript(scriptLocalPath, user string)
- func CopyFile(dst, src string) error
- func CopyFileMust(dst, src string)
- func CreateDir(dir string) error
- func CreateDirForFile(path string) error
- func CreateDirForFileMust(path string) string
- func CreateDirMust(path string) string
- func CreateZipFile(dst string, baseDir string, toZip ...string)
- func CreateZipWithDirContent(zipFilePath, dirToZip string) error
- func CurrDirAbsMust() string
- func DecodeBase64(s string) (int, error)
- func DeleteFilesIf(dir string, shouldDelete func(os.FileInfo) bool) error
- func DirCopyRecur(dstDir, srcDir string, shouldCopyFn func(path string) bool) ([]string, error)
- func DirCopyRecurMust(dstDir, srcDir string, shouldCopyFn func(path string) bool) []string
- func DirExists(path string) bool
- func DurationToString(d time.Duration) string
- func EncodeBase64(n int) string
- func EnsureGitClean(dir string)
- func ExpandTildeInPath(s string) string
- func FileExists(path string) bool
- func FileLineCount(path string) (int, error)
- func FilesSameSize(path1, path2 string) bool
- func FmtArgs(args ...interface{}) string
- func FmtCmdShort(cmd exec.Cmd) string
- func FmtSizeHuman(size int64) string
- func FmtSmart(format string, args ...interface{}) string
- func FormatDuration(d time.Duration) string
- func GetFileSize(path string) (int64, error)
- func GitPullMust(dir string)
- func GitStatusMust(dir string) string
- func GzipFile(dstPath, srcPath string) error
- func IndentStr(n int) string
- func IsGitClean(dir string) bool
- func IsLinux() bool
- func IsMac() bool
- func IsMinioNotExistsError(err error) bool
- func ListFilesInDir(dir string, recursive bool) []string
- func Logf(format string, args ...interface{})
- func LoginAsRoot()
- func MakeExecScript(name string) string
- func MimeTypeFromFileName(path string) string
- func Must(err error)
- func NormalizeNewlines(d []byte) []byte
- func OpenBrowser(url string) error
- func OpenCodeDiffMust(path1, path2 string)
- func OpenFileMaybeCompressed(path string) (io.ReadCloser, error)
- func OpenNotepadWithFileMust(path string)
- func PanicIf(cond bool, args ...interface{})
- func PanicIfErr(err error, args ...interface{})
- func PathExists(path string) bool
- func PathIsDir(path string) (isDir bool, err error)
- func PathMatchesExtensions(path string, extensions []string) bool
- func PrintFileSize(path string)
- func PrintLineStats(stats *LineStats)
- func ReadFileMaybeCompressed(path string) ([]byte, error)
- func ReadFileMust(path string) []byte
- func ReadLinesFromFile(path string) ([]string, error)
- func ReadLinesFromReader(r io.Reader) ([]string, error)
- func ReadZipFileMust(path string) map[string][]byte
- func RemoveDuplicateStrings(a []string) []string
- func RemoveFileLogged(path string)
- func RemoveFilesInDirMust(dir string)
- func RequestGetFullHost(r *http.Request) string
- func RequestGetProtocol(r *http.Request) string
- func RequestGetRemoteAddress(r *http.Request) string
- func RunCmdLoggedMust(cmd *exec.Cmd) string
- func RunCmdMust(cmd *exec.Cmd) string
- func ScpCopy(localSrcPath string, serverDstPath string)
- func SetPublicObjectMetadata(opts *minio.PutObjectOptions)
- func Sha1HexOfBytes(data []byte) string
- func Sha1HexOfFile(path string) (string, error)
- func Sha1OfBytes(data []byte) []byte
- func Sha1OfFile(path string) ([]byte, error)
- func SshExec(user string, script string)
- func SshInteractive(user string)
- func StringInSlice(a []string, toCheck string) bool
- func StringRemoveFromSlice(a []string, toRemove string) ([]string, bool)
- func StringsRemoveFirst(a []string) []string
- func TimeSinceNowAsString(t time.Time) string
- func UserHomeDirMust() string
- func UtcNow() time.Time
- func WaitForCtrlC()
- func WriteFileCreateDirMust(d []byte, path string) error
- func WriteFileGzipped(path string, data []byte) error
- func WriteFileMust(path string, data []byte)
- type FileWalk
- type FileWalkEntry
- type FilterFunc
- type FormattedDuration
- type LineCount
- type LineStats
- type MinioClient
- func (c *MinioClient) Delete(remotePath string) error
- func (c *MinioClient) DownloadFileAsData(remotePath string) ([]byte, error)
- func (c *MinioClient) DownloadFileAtomically(dstPath string, remotePath string) error
- func (c *MinioClient) EnsureConfigured()
- func (c *MinioClient) GetClient() (*minio.Client, error)
- func (c *MinioClient) ListRemoteFiles(prefix string) ([]*minio.ObjectInfo, error)
- func (c *MinioClient) StatObject(remotePath string) (minio.ObjectInfo, error)
- func (c *MinioClient) URLBase() string
- func (c *MinioClient) UploadData(remotePath string, d []byte, opts minio.PutObjectOptions) error
- func (c *MinioClient) UploadDataPublic(remotePath string, d []byte) error
- func (c *MinioClient) UploadFile(remotePath string, filePath string, public bool) error
- func (c *MinioClient) UploadFilePrivate(remotePath string, filePath string) error
- func (c *MinioClient) UploadFilePublic(remotePath string, filePath string) error
- func (c *MinioClient) UploadReader(remotePath string, r io.Reader, size int64, public bool, contentType string) error
- func (c *MinioClient) UploadReaderPrivate(remotePath string, r io.Reader, size int64, contentType string) error
- func (c *MinioClient) UploadReaderPublic(remotePath string, r io.Reader, size int64, contentType string) error
- func (c *MinioClient) UploadStringPrivate(remotePath string, s string) error
- func (c *MinioClient) UploadStringPublic(remotePath string, s string) error
Constants ¶
This section is empty.
Variables ¶
var ( ServerIPAddress string IdentityFilePath string )
var (
LogFile io.Writer
)
Functions ¶
func AreFilesEuqalMust ¶
func CdUpDir ¶
func CdUpDir(dirName string)
we are executed for do/ directory so top dir is parent dir
func CloseNoError ¶
CloseNoError is like io.Closer Close() but ignores an error use as: defer CloseNoError(f)
func CopyAndExecServerScript ¶
func CopyAndExecServerScript(scriptLocalPath, user string)
CopyAndExecServerScript copies a given script to the server and executes it under a given user name
func CreateDirForFile ¶
CreateDirForFile creates intermediary directories for a file
func CreateDirForFileMust ¶
CreateDirForFileMust is like CreateDirForFile. Panics on error.
func CreateDirMust ¶
CreateDirMust creates a directory. Panics on error
func CreateZipFile ¶
toZip is a list of files and directories in baseDir Directories are added recursively
func CreateZipWithDirContent ¶
CreateZipWithDirContent creates a zip file with the content of a directory. The names of files inside the zip file are relatitve to dirToZip e.g. if dirToZip is foo and there is a file foo/bar.txt, the name in the zip will be bar.txt
func CurrDirAbsMust ¶
func CurrDirAbsMust() string
CurrDirAbsMust returns absolute path of the current directory
func DeleteFilesIf ¶
DeleteFilesIf deletes a files in a given directory if shouldDelete callback returns true
func DirCopyRecur ¶
func DirCopyRecurMust ¶
func DurationToString ¶
DurationToString converts duration to a string
func EnsureGitClean ¶
func EnsureGitClean(dir string)
func ExpandTildeInPath ¶
ExpandTildeInPath converts ~ to $HOME
func FileExists ¶
FileExists returns true if a given path exists and is a file
func FileLineCount ¶
FileLineCount returns number of lines in a file
func FilesSameSize ¶
func FmtArgs ¶
func FmtArgs(args ...interface{}) string
FmtArgs formats args as a string. First argument should be format string and the rest are arguments to the format
func FmtCmdShort ¶
FmtCmdShort formats exec.Cmd in a short way
func FmtSizeHuman ¶
func FormatDuration ¶
FormatDuration formats duration in a more human friendly way than time.Duration.String()
func GetFileSize ¶
GetFileSize returns size of the file
func GitPullMust ¶
func GitPullMust(dir string)
func GitStatusMust ¶
func IsGitClean ¶
func IsMinioNotExistsError ¶
IsMinioNotExistsError returns true if an error indicates that a key doesn't exist in storage
func ListFilesInDir ¶
ListFilesInDir returns a list of files in a directory
func Logf ¶
func Logf(format string, args ...interface{})
a centralized place allows us to tweak logging, if need be
func LoginAsRoot ¶
func LoginAsRoot()
func MakeExecScript ¶
func MimeTypeFromFileName ¶
func NormalizeNewlines ¶
NormalizeNewLines changes CR and CRLF into LF
func OpenBrowser ¶
OpenBrowsers open web browser with a given url (can be http:// or file://)
func OpenCodeDiffMust ¶
func OpenCodeDiffMust(path1, path2 string)
func OpenFileMaybeCompressed ¶
func OpenFileMaybeCompressed(path string) (io.ReadCloser, error)
OpenFileMaybeCompressed opens a file that might be compressed with gzip or bzip2. TODO: could sniff file content instead of checking file extension
func OpenNotepadWithFileMust ¶
func OpenNotepadWithFileMust(path string)
func PanicIfErr ¶
func PanicIfErr(err error, args ...interface{})
PanicIfErr panics if err is not nil
func PathExists ¶
PathExists returns true if a filesystem path exists Treats any error (e.g. lack of access due to permissions) as non-existence
func PathIsDir ¶
PathIsDir returns true if a path exists and is a directory Returns false, nil if a path exists and is not a directory (e.g. a file) Returns undefined, error if there was an error e.g. because a path doesn't exists
func PathMatchesExtensions ¶
PathMatchesExtensions returns true if path matches any of the extensions
func PrintFileSize ¶
func PrintFileSize(path string)
func PrintLineStats ¶
func PrintLineStats(stats *LineStats)
func ReadFileMaybeCompressed ¶
ReadFileMaybeCompressed reads file. Ungzips if it's gzipped.
func ReadLinesFromFile ¶
ReadLinesFromFile reads all lines from a file. Newlines are not included.
func ReadLinesFromReader ¶
ReadLinesFromReader reads all lines from io.Reader. Newlines are not included.
func ReadZipFileMust ¶
func RemoveDuplicateStrings ¶
RemoveDuplicateStrings removes duplicate strings from an array of strings. It's optimized for the case of no duplicates. It modifes a in place.
func RemoveFileLogged ¶
func RemoveFileLogged(path string)
RemoveFileLogged removes a file and logs the action
func RemoveFilesInDirMust ¶
func RemoveFilesInDirMust(dir string)
RemoveFilesInDirMust removes all files in a directory (but not sub-directories)
func RequestGetFullHost ¶
RequestGetFullHost returns full host name e.g. "https://blog.kowalczyk.info/"
func RequestGetProtocol ¶
RequestGetProtocol returns protocol under which the request is being served i.e. "http" or "https"
func RequestGetRemoteAddress ¶
RequestGetRemoteAddress returns ip address of the client making the request, taking into account http proxies
func RunCmdLoggedMust ¶
RunCmdLoggedMust runs a command and returns its stdout Shows output as it happens
func RunCmdMust ¶
RunCmdMust runs a command and returns its stdout
func SetPublicObjectMetadata ¶
func SetPublicObjectMetadata(opts *minio.PutObjectOptions)
SetPublicObjectMetadata sets options that mark object as public for doing put operation
func Sha1HexOfBytes ¶
Sha1HexOfBytes returns 40-byte hex sha1 of bytes
func Sha1HexOfFile ¶
Sha1HexOfFile returns 40-byte hex sha1 of file content
func Sha1OfFile ¶
Sha1OfFile returns 20-byte sha1 of file content
func SshInteractive ¶
func SshInteractive(user string)
func StringInSlice ¶
StringInSlice returns true if a string is present in slice
func StringRemoveFromSlice ¶
StringRemoveFromSlice removes a given string from a slice of strings returns a (potentially) new slice and true if was removed
func StringsRemoveFirst ¶
StringsRemoveFirst removes first sstring from the slice
func TimeSinceNowAsString ¶
TimeSinceNowAsString returns string version of time since a ginve timestamp
func WriteFileCreateDirMust ¶
WriteFileCreateDirMust is like ioutil.WriteFile() but also creates intermediary directories
func WriteFileGzipped ¶
WriteFileGzipped writes data to a path, using best gzip compression
func WriteFileMust ¶
WriteFileMust writes data to a file
Types ¶
type FileWalk ¶
type FileWalk struct { FilesChan chan *FileWalkEntry // contains filtered or unexported fields }
FileWalk describes a file traversal
func StartFileWalk ¶
StartFileWalk starts a file traversal from startDir
type FileWalkEntry ¶
FileWalkEntry describes a single file from FileWalk
func (*FileWalkEntry) Path ¶
func (e *FileWalkEntry) Path() string
Path returns full path of the file
type FilterFunc ¶
func MakeAllowedFileFilterForExts ¶
func MakeAllowedFileFilterForExts(exts ...string) FilterFunc
func MakeExcludeDirsFilter ¶
func MakeExcludeDirsFilter(dirs ...string) FilterFunc
func MakeFilterAnd ¶
func MakeFilterAnd(filters ...FilterFunc) FilterFunc
func MakeFilterOr ¶
func MakeFilterOr(filters ...FilterFunc) FilterFunc
type FormattedDuration ¶
time.Duration with a better string representation
func (FormattedDuration) String ¶
func (d FormattedDuration) String() string
type MinioClient ¶
type MinioClient struct { StorageKey string StorageSecret string Bucket string Endpoint string // e.g. "nyc3.digitaloceanspaces.com" Secure bool // contains filtered or unexported fields }
MinioClient represents s3/spaces etc. client
func (*MinioClient) Delete ¶
func (c *MinioClient) Delete(remotePath string) error
func (*MinioClient) DownloadFileAsData ¶
func (c *MinioClient) DownloadFileAsData(remotePath string) ([]byte, error)
func (*MinioClient) DownloadFileAtomically ¶
func (c *MinioClient) DownloadFileAtomically(dstPath string, remotePath string) error
func (*MinioClient) EnsureConfigured ¶
func (c *MinioClient) EnsureConfigured()
EnsureCondfigured will panic if client not configured
func (*MinioClient) GetClient ¶
func (c *MinioClient) GetClient() (*minio.Client, error)
GetClient returns a (cached) minio client
func (*MinioClient) ListRemoteFiles ¶
func (c *MinioClient) ListRemoteFiles(prefix string) ([]*minio.ObjectInfo, error)
ListRemoveFiles returns a list of files under a given prefix
func (*MinioClient) StatObject ¶
func (c *MinioClient) StatObject(remotePath string) (minio.ObjectInfo, error)
func (*MinioClient) URLBase ¶
func (c *MinioClient) URLBase() string
URLBase returns base of url under which files are accesible (if public it's a publicly available file)
func (*MinioClient) UploadData ¶
func (c *MinioClient) UploadData(remotePath string, d []byte, opts minio.PutObjectOptions) error
func (*MinioClient) UploadDataPublic ¶
func (c *MinioClient) UploadDataPublic(remotePath string, d []byte) error
func (*MinioClient) UploadFile ¶
func (c *MinioClient) UploadFile(remotePath string, filePath string, public bool) error
func (*MinioClient) UploadFilePrivate ¶
func (c *MinioClient) UploadFilePrivate(remotePath string, filePath string) error
func (*MinioClient) UploadFilePublic ¶
func (c *MinioClient) UploadFilePublic(remotePath string, filePath string) error
func (*MinioClient) UploadReader ¶
func (*MinioClient) UploadReaderPrivate ¶
func (*MinioClient) UploadReaderPublic ¶
func (*MinioClient) UploadStringPrivate ¶
func (c *MinioClient) UploadStringPrivate(remotePath string, s string) error
func (*MinioClient) UploadStringPublic ¶
func (c *MinioClient) UploadStringPublic(remotePath string, s string) error