utils

package
v3.0.15+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BashCmdExec

func BashCmdExec(cmd string, workingDir string, environ []string, logPrefix string) error

func CmdExec

func CmdExec(cmdName string, cmdArgs []string, workingDir string, environ []string, logPrefix string) error

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func FileExists

func FileExists(filePath string) bool

func GitCheckout

func GitCheckout(repoPath string, branchName string) error

func GitClone

func GitClone(parentPath string, repositoryName string, gitRemote string) (string, error)

Clone a git repo into a local directory. Credentials need to be specified by embedding in gitRemote url. TODO: this pattern may not work on Bitbucket/GitLab

func GitCommit

func GitCommit(repoPath string, message string, signature *git2go.Signature) error

Add all modified files to index, and commit.

func GitFindNearestTagName

func GitFindNearestTagName(repoPath string) (string, error)

Get the nearest tag on branch. tag must be nearest, ie. sorted by their distance from the HEAD of the branch, not the date or tagname. basically `git describe --tags --abbrev=0`

func GitGenerateChangelog

func GitGenerateChangelog(repoPath string, baseSha string, headSha string) (string, error)

func GitGenerateGitIgnore

func GitGenerateGitIgnore(repoPath string, ignoreType string) error

func GitGetTagDetails

func GitGetTagDetails(repoPath string, tagName string) (*pipeline.GitTagDetails, error)

func GitPush

func GitPush(repoPath string, localBranch string, remoteBranch string, tagName string) error

func GitSignature

func GitSignature(authorName string, authorEmail string) *git2go.Signature

func GitTag

func GitTag(repoPath string, version string, message string, signature *git2go.Signature) (string, error)

func LeftPad

func LeftPad(s string, padStr string, pLen int) string

func LeftPad2Len

func LeftPad2Len(s string, padStr string, overallLen int) string

func PopulateTemplate

func PopulateTemplate(tmplString string, data interface{}) (string, error)

func RightPad

func RightPad(s string, padStr string, pLen int) string

func RightPad2Len

func RightPad2Len(s string, padStr string, overallLen int) string

func SnakeCaseToCamelCase

func SnakeCaseToCamelCase(inputUnderScoreStr string) (camelCase string)

func StripIndent

func StripIndent(multilineStr string) string

func UnsetEnv

func UnsetEnv(prefix string) (restore func())

UnsetEnv unsets all envars having prefix and returns a function that restores the env. Any newly added envars having prefix are also unset by restore. It is idiomatic to use with a defer.

defer UnsetEnv("ACME_")()

Note that modifying the env may have unpredictable results when tests are run with t.Parallel. NOTE: This is quick n' dirty from memory; write some tests for this code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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