Documentation ¶
Index ¶
- Constants
- Variables
- func AsBool(unk interface{}) (bool, error)
- func AsFloat64(unk interface{}) (float64, error)
- func AsInt64(unk interface{}) (int64, error)
- func AsMapOfStringsIntefaces(unk interface{}) (map[string]interface{}, error)
- func AsSliceOfStrings(unk interface{}) ([]string, error)
- func AsString(unk interface{}) (string, error)
- func AtoInt32(text string) (int32, error)
- func BackupDir() (string, error)
- func BasicAuth(username, password string) string
- func CacheDir() (string, error)
- func CallWithExponentialBackOff(url string, auth string, httpMethod string, reqBody []byte, ...) ([]byte, error)
- func CheckMark() string
- func ColorNameValues() []string
- func CombineMapTrees(destination map[string]interface{}, input map[string]interface{})
- func ConfigDir() (string, error)
- func Confirm(message string, defaultValue bool, help string, handles IOFileHandles) (bool, error)
- func Contains(arr []string, str string) bool
- func ContentTypeForFileName(name string) string
- func ConvertAllMapKeysToString(i interface{}) interface{}
- func CopyDir(src string, dst string, force bool) (err error)
- func CopyDirOverwrite(src string, dst string) (err error)
- func CopyDirPreserve(src string, dst string) error
- func CopyFile(src, dst string) (err error)
- func CopyFileOrDir(src string, dst string, force bool) (err error)
- func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error)
- func DeleteDirContents(dir string) error
- func DeleteDirContentsExcept(dir string, exceptDir string) error
- func DeleteFile(fileName string) (err error)
- func DereferenceBool(b *bool) bool
- func DereferenceFloat64(f *float64) float64
- func DereferenceInt(i *int) int
- func DereferenceInt64(i *int64) int64
- func DereferenceString(s *string) string
- func DestroyFile(filename string) error
- func DiffSlices(oldSlice []string, newSlice []string) ([]string, []string)
- func DirExists(path string) (bool, error)
- func DownloadFile(filepath string, url string) (err error)
- func DraftDir() (string, error)
- func DurationString(start *metav1.Time, end *metav1.Time) string
- func EncodeKubernetesName(name string) string
- func EnvironmentsDir() (string, error)
- func ExtractKeyValuePairs(values []string, sep string) (map[string]string, error)
- func FileExists(path string) (bool, error)
- func FileIsEmpty(path string) (bool, error)
- func FilterFileExists(paths []string) []string
- func FirstFileExists(paths ...string) (string, error)
- func FirstNotEmptyString(values ...string) string
- func FormatDate(t time.Time) string
- func GenerateSchema(target interface{}) *schemagen.Schema
- func GetAndCleanEnviron(keys []string) (map[string]string, error)
- func GetBasicAuthUserAndPassword(auth string) (string, string)
- func GetClient() *http.Client
- func GetClientWithTimeout(duration time.Duration) *http.Client
- func GetColor(optionName string, colorNames []string) (*color.Color, error)
- func GetCustomClient(transport http.RoundTripper, timeout int) *http.Client
- func GetLatestFullTagFromGithub(githubOwner, githubRepo string) (*github.RepositoryTag, error)
- func GetLatestReleaseFromGitHub(githubOwner, githubRepo string) (string, error)
- func GetLatestReleaseFromGitHubURL(gitURL string) (string, error)
- func GetLatestTagFromGithub(githubOwner, githubRepo string) (string, error)
- func GetLatestVersionFromGitHub(githubOwner, githubRepo string) (semver.Version, error)
- func GetLatestVersionStringFromBucketURLs(versionStrings []string) (semver.Version, error)
- func GetLatestVersionStringFromGitHub(githubOwner, githubRepo string) (string, error)
- func GetMapValueAsIntViaPath(m map[string]interface{}, path string) int
- func GetMapValueAsMapViaPath(m map[string]interface{}, path string) map[string]interface{}
- func GetMapValueAsStringViaPath(m map[string]interface{}, path string) string
- func GetMapValueViaPath(m map[string]interface{}, path string) interface{}
- func GetMockAPIResponseFromFile(dataDir string, route MethodMap) mocker
- func GetSh() string
- func GetTagsFromGithub(githubOwner, githubRepo string) ([]*github.RepositoryTag, error)
- func GitCredentialsFile() string
- func GlobAllFiles(basedir string, pattern string, fn func(string) error) error
- func HashPassword(password string) string
- func HomeDir() string
- func IgnoreFile(path string, ignores []string) (bool, error)
- func Int32ToA(n int32) string
- func InvalidArg(value string, values []string) error
- func InvalidArgError(value string, err error) error
- func InvalidArgf(value string, message string, a ...interface{}) error
- func InvalidOption(name string, value string, values []string) error
- func InvalidOptionError(option string, value interface{}, err error) error
- func InvalidOptionf(option string, value interface{}, message string, a ...interface{}) error
- func IsEmpty(name string) (bool, error)
- func IsValidUrl(s string) bool
- func IsZeroOfUnderlyingType(x interface{}) bool
- func JXBinLocation() (string, error)
- func JXBinaryLocation() (string, error)
- func KeyValuesToMap(values []string) map[string]string
- func KillProcesses(binary string) error
- func KillProcessesTree(binary string, processes []*process.Process, m map[int32]bool) (bool, error)
- func KubeConfigFile() string
- func ListDirectory(root string, recurse bool) error
- func LoadBytes(dir, name string) ([]byte, error)
- func LoadCacheData(fileName string, loader CacheLoader) ([]byte, error)
- func LocalFileSystemSecretsDir() (string, error)
- func LogsDir() (string, error)
- func MapKeys(m map[string]string) []string
- func MapToKeyValues(values map[string]string) []string
- func MapToString(m map[string]string) string
- func MarkdownLink(text string, url string) string
- func MavenBinaryLocation() (string, error)
- func MergeMaps(maps ...map[string]string) map[string]string
- func MissingArgument(name string) error
- func MissingEnv(name string) error
- func MissingOption(name string) error
- func MissingOptionWithOptions(name string, options []string) error
- func OrganisationsDir() (string, error)
- func Pad(s, pad string, width int, align int) string
- func PadCenter(s, pad string, width int) string
- func PadLeft(s, pad string, width int) string
- func PadRight(s, pad string, width int) string
- func ParseBool(text string) (bool, error)
- func ParseDate(dateText string) (time.Time, error)
- func PathWithBinary(customPaths ...string) string
- func PickName(names []string, message string, help string, handles IOFileHandles) (string, error)
- func PickNameWithDefault(names []string, message string, defaultValue string, help string, ...) (string, error)
- func PickNames(names []string, message string, help string, handles IOFileHandles) ([]string, error)
- func PickNamesWithDefaults(names []string, defaults []string, message string, help string, ...) ([]string, error)
- func PickPassword(message string, help string, handles IOFileHandles) (string, error)
- func PickRequiredNameWithDefault(names []string, message string, defaultValue string, help string, ...) (string, error)
- func PickValue(message string, defaultValue string, required bool, help string, ...) (string, error)
- func PluginBinDir(ns string) (string, error)
- func PomFlavour(path string) (string, error)
- func PrettyPrint(i interface{}) string
- func QuestionAnswer(question string, answer string) string
- func RandStringBytesMaskImprSrc(n int) (string, error)
- func RecreateDirs(dirs ...string) error
- func RegexpSplit(text string, regexSeperator string) []string
- func RemoveScheme(u string) string
- func RemoveStringFromSlice(strings []string, toRemove string) []string
- func RenameDir(src string, dst string, force bool) (err error)
- func RenameFile(src string, dst string) (err error)
- func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func(groups []Group) []string) string
- func RestoreEnviron(environ map[string]string) error
- func Retry(maxElapsedTime time.Duration, f func() error) error
- func RetryWithInitialDelay(initialDelay, maxElapsedTime time.Duration, f func() error) error
- func RetryWithInitialDelaySlower(initialDelay, maxElapsedTime time.Duration, f func() error) error
- func ReverseStrings(a []string)
- func RunCommandBackground(name string, output io.Writer, verbose bool, args ...string) error
- func SanitizeLabel(label string) string
- func SanitizeURL(unsanitizedUrl string) string
- func SelectNames(names []string, message string, selectAll bool, help string, ...) ([]string, error)
- func SelectNamesWithFilter(names []string, message string, selectAll bool, filter string, help string, ...) ([]string, error)
- func SetMapValueViaPath(m map[string]interface{}, path string, value interface{})
- func SortedMapKeys(m map[string]string) []string
- func StartsWith(s, substr string) bool
- func StringArrayHasPrefixIndex(array []string, prefix string) int
- func StringArrayIndex(array []string, value string) int
- func StringArrayToLower(values []string) []string
- func StringArraysEqual(a1 []string, a2 []string) bool
- func StringContainsAny(text string, includes []string, excludes []string) bool
- func StringIndexes(text string, value string) []int
- func StringMapHasValue(m map[string]string, value string) bool
- func StringMatchesAny(text string, includes []string, excludes []string) bool
- func StringMatchesPattern(text string, pattern string) bool
- func StringsContaining(slice []string, filter string) []string
- func StripTrailingSlash(url string) string
- func SuggestionsFor(typedName string, values []string, suggestionsMinimumDistance int, ...) []string
- func ToCamelCase(s string) string
- func ToMapStringInterfaceFromStruct(obj interface{}) (map[string]interface{}, error)
- func ToObjectMap(object interface{}) (map[string]interface{}, error)
- func ToStringMapStringFromStruct(obj interface{}) map[string]string
- func ToStructFromMapStringInterface(m map[string]interface{}, str interface{}) error
- func ToValidFileSystemName(name string) string
- func URLToHostName(svcURL string) string
- func UnTarFile(header *tar.Header, target string, tarReader io.Reader) error
- func UnTargz(tarball, target string, onlyFiles []string) error
- func UnTargzAll(tarball, target string) error
- func Unzip(src, dest string) error
- func UnzipSpecificFiles(src, dest string, onlyFiles ...string) error
- func UrlEqual(url1, url2 string) bool
- func UrlHostNameWithoutPort(rawUri string) (string, error)
- func UrlJoin(paths ...string) string
- func ValidateYaml(target interface{}, data []byte) ([]string, error)
- func WriteJenkinsfileStatements(indentCount int, statements []*Statement) string
- func YesNo(t bool) string
- type CacheLoader
- type Command
- func (c *Command) Attempts() int
- func (c *Command) CurrentArgs() []string
- func (c *Command) CurrentDir() string
- func (c *Command) CurrentEnv() map[string]string
- func (c *Command) CurrentName() string
- func (c *Command) DidError() bool
- func (c *Command) DidFail() bool
- func (c *Command) Error() error
- func (c *Command) Run() (string, error)
- func (c *Command) RunWithoutRetry() (string, error)
- func (c *Command) SetArgs(args []string)
- func (c *Command) SetDir(dir string)
- func (c *Command) SetEnv(env map[string]string)
- func (c *Command) SetEnvVariable(name string, value string)
- func (c *Command) SetExponentialBackOff(backoff *backoff.ExponentialBackOff)
- func (c *Command) SetName(name string)
- func (c *Command) SetTimeout(timeout time.Duration)
- func (c *Command) String() string
- type CommandError
- type Commander
- type Group
- type IOFileHandles
- type MethodMap
- type Router
- type Statement
- type Writer
Constants ¶
const ( // PlaceHolderPrefix is prefix for placeholders PlaceHolderPrefix = "REPLACE_ME" // PlaceHolderAppName placeholder for app name PlaceHolderAppName = PlaceHolderPrefix + "_APP_NAME" // PlaceHolderGitProvider placeholder for git provider PlaceHolderGitProvider = PlaceHolderPrefix + "_GIT_PROVIDER" // PlaceHolderOrg placeholder for org PlaceHolderOrg = PlaceHolderPrefix + "_ORG" // PlaceHolderDockerRegistryOrg placeholder for docker registry PlaceHolderDockerRegistryOrg = PlaceHolderPrefix + "_DOCKER_REGISTRY_ORG" // DefaultGitUserName default value to use for git "user.name" DefaultGitUserName = "jenkins-x-bot" // DefaultGitUserEmail default value to use for git "user.email" DefaultGitUserEmail = "jenkins-x@googlegroups.com" // EnvVarBranchName is the environment variable that will hold the name of the branch being built during pipelines EnvVarBranchName = "BRANCH_NAME" )
const ( DefaultWritePermissions = 0760 // DefaultFileWritePermissions default permissions when creating a file DefaultFileWritePermissions = 0644 MaximumNewDirectoryAttempts = 1000 )
const ( ALIGN_LEFT = 0 ALIGN_CENTER = 1 ALIGN_RIGHT = 2 )
const ( MAVEN = "maven" MAVEN_JAVA11 = "maven-java11" APPSERVER = "appserver" LIBERTY = "liberty" DROPWIZARD = "dropwizard" )
const DateFormat = "January 2 2006"
const (
DefaultSuggestionsMinimumDistance = 2
)
Variables ¶
var ColorAnswer = color.New(color.FgCyan).SprintFunc()
ColorAnswer returns a new function that returns answer-colorized (cyan) strings for the given arguments with fmt.Sprint().
var ColorBold = color.New(color.Bold).SprintFunc()
ColorBold returns a new function that returns bold-colorized (bold) strings for the given arguments with fmt.Sprint().
var ColorError = color.New(color.FgRed).SprintFunc()
ColorError returns a new function that returns error-colorized (red) strings for the given arguments with fmt.Sprint().
var ColorInfo = color.New(color.FgGreen).SprintFunc()
ColorInfo returns a new function that returns info-colorized (green) strings for the given arguments with fmt.Sprint().
var ColorStatus = color.New(color.FgBlue).SprintFunc()
ColorStatus returns a new function that returns status-colorized (blue) strings for the given arguments with fmt.Sprint().
var ColorWarning = color.New(color.FgYellow).SprintFunc()
ColorWarning returns a new function that returns warning-colorized (yellow) strings for the given arguments with fmt.Sprint().
var DisallowedLabelCharacters = regexp.MustCompile("[^a-z0-9-]")
DisallowedLabelCharacters regex of chars not allowed in lables
Functions ¶
func AsMapOfStringsIntefaces ¶
AsMapOfStringsIntefaces attempts to convert unk to a map[string]interface{}
func AsSliceOfStrings ¶
AsSliceOfStrings attempts to convert unk to a slice of strings
func CallWithExponentialBackOff ¶
func CallWithExponentialBackOff(url string, auth string, httpMethod string, reqBody []byte, reqParams url.Values) ([]byte, error)
CallWithExponentialBackOff make a http call with exponential backoff retry
func CheckMark ¶
func CheckMark() string
CheckMark returns the check mark unicode character. We could configure this to use no color or avoid unicode using platform, env vars or config?
func ColorNameValues ¶
func ColorNameValues() []string
ColorNameValues returns all the color names sorted
func CombineMapTrees ¶
CombineMapTrees recursively copies all the values from the input map into the destination map preserving any missing entries in the destination
func ContentTypeForFileName ¶
ContentTypeForFileName returns the MIME type for the given file name
func ConvertAllMapKeysToString ¶
func ConvertAllMapKeysToString(i interface{}) interface{}
ConvertAllMapKeysToString will recursively go through an object and convert all keys of a map (and any submaps) to Strings. This is necessary for json handlers (eg vault) where an item of a submap must be map[string]interface{} rather than the more lenient map[interface{}]interface{} that you get from yaml unmarshalling
func CopyDirOverwrite ¶
CopyDirOverwrite copies from the source dir to the destination dir overwriting files along the way
func CopyDirPreserve ¶
CopyDirPreserve copies from the src dir to the dst dir if the file does NOT already exist in dst
func CopyFileOrDir ¶
CopyFileOrDir copies the source file or directory to the given destination
func CreateUniqueDirectory ¶
CreateUniqueDirectory creates a new directory but if the combination of dir and name exists then append a number until a unique name is found
func DeleteDirContents ¶
DeleteDirContents removes all the contents of the given directory
func DeleteDirContentsExcept ¶
func DeleteFile ¶
DeleteFile deletes a file from the operating system. This should NOT be used to delete any sensitive information because it can easily be recovered. Use DestroyFile to delete sensitive information
func DereferenceBool ¶
DereferenceBool will return the bool value or the empty value for bool
func DereferenceFloat64 ¶
DereferenceFloat64 will return the float64 value or the empty value for float64
func DereferenceInt ¶
DereferenceInt will return the int value or the empty value for int
func DereferenceInt64 ¶
DereferenceInt64 will return the int value or the empty value for i
func DereferenceString ¶
DereferenceString will return the string value or the empty value for string
func DestroyFile ¶
DestroyFile will securely delete a file by first overwriting it with random bytes, then deleting it. This should always be used for deleting sensitive information
func DiffSlices ¶
DiffSlices compares the two slices and returns an array of items to delete from the old slice and a slice of new values to add to
func DownloadFile ¶
Download a file from the given URL
func DurationString ¶
DurationString returns the duration between start and end time as string
func EncodeKubernetesName ¶
EncodeKubernetesName takes a string and turns it into a form suitable for use as a Kubernetes name. Note there is no decode functionality provided atm (and things like escaping escape codes aren't handled), so round-tripping is not possible yet. K8S names are lower case, numbers, '-', and '.'. Invalid characters are percent-encoded in a _similar_ way to URL encoding, with a period ('.') followed by the numerical character code. Conversion is:
Upper case letters -> lower case. 'a-z', '0-9', '-', '.' -> left as-is. Any other characters: percent-encoded ('.' + rune hex code).
func EnvironmentsDir ¶
func ExtractKeyValuePairs ¶
ExtractKeyValuePairs creates a map of an string array assuming that each array element is of the form <key><sep><value>. An error is returned is a array element cannot be split into a key/value pair using the specified separator.
func FileExists ¶
FileExists checks if path exists and is a file
func FileIsEmpty ¶
FileIsEmpty checks if a file is empty
func FilterFileExists ¶
FilterFileExists filters out files which do not exist
func FirstFileExists ¶
FirstFileExists returns the first file which exists or an error if we can't detect if a file that exists
func FirstNotEmptyString ¶
FirstNotEmptyString returns the first non empty string or the empty string if none can be found
func FormatDate ¶
func GenerateSchema ¶
GenerateSchema generates a JSON schema for the given struct type and returns it.
func GetAndCleanEnviron ¶
GetAndCleanEnviron cleans the provided env variables and returns their current value
func GetClientWithTimeout ¶
GetClientWithTimeout returns a client with JX default transport and user specified timeout
func GetCustomClient ¶
func GetCustomClient(transport http.RoundTripper, timeout int) *http.Client
GetCustomClient returns a client with user specified transport and timeout (in seconds)
func GetLatestFullTagFromGithub ¶
func GetLatestFullTagFromGithub(githubOwner, githubRepo string) (*github.RepositoryTag, error)
GetLatestFullTagFromGithub gets the latest 'full' tag from a specific github repo. This (at present) ignores releases with a hyphen in it, usually used with -SNAPSHOT, or -RC1 or -beta
func GetLatestReleaseFromGitHub ¶
GetLatestReleaseFromGitHub gets the latest Release from a specific github repo
func GetLatestReleaseFromGitHubURL ¶
GetLatestReleaseFromGitHubURL returns the latest release version for the git URL
func GetLatestTagFromGithub ¶
GetLatestTagFromGithub gets the latest (in github order) tag from a specific github repo
func GetLatestVersionStringFromBucketURLs ¶
GetLatestVersionStringFromBucketURLs return the latest version from a list of buckets with the version at the end of the path
func GetMapValueAsIntViaPath ¶
GetMapValueAsIntViaPath returns the int value at the given path mean `m["foo"]["bar"]["whatnot"]`
func GetMapValueAsMapViaPath ¶
GetMapValueAsMapViaPath returns the map value at the given path mean `m["foo"]["bar"]["whatnot"]`
func GetMapValueAsStringViaPath ¶
GetMapValueAsStringViaPath returns the string value at the given path mean `m["foo"]["bar"]["whatnot"]`
func GetMapValueViaPath ¶
GetMapValueViaPath returns the value at the given path mean `m["foo"]["bar"]["whatnot"]`
func GetMockAPIResponseFromFile ¶
@param dataDir Location of test data json file @param router Should map a URL path to a map that maps a method to a JSON response file name. Conceptually: (url, method) -> file See pkg/gits/bitbucket_cloud_test.go for an example.
func GetSh ¶
func GetSh() string
GetSh returns the default sh path. Windows returns sh, other platform returns /bin/sh.
func GetTagsFromGithub ¶
func GetTagsFromGithub(githubOwner, githubRepo string) ([]*github.RepositoryTag, error)
GetTagsFromGithub gets the list of tags on a specific github repo
func GitCredentialsFile ¶
func GitCredentialsFile() string
GitCredentialsFile returns the location of the git credentials file
func GlobAllFiles ¶
GlobAllFiles performs a glob on the pattern and then processes all the files found. if a folder matches the glob its treated as another glob to recurse into the directory
func HashPassword ¶
HashPassword hashes the given password with SHA1
func IgnoreFile ¶
IgnoreFile returns true if the path matches any of the ignores. The match is the same as filepath.Match.
func InvalidArg ¶
func InvalidArgError ¶
func InvalidArgf ¶
func InvalidOptionError ¶
InvalidOptionError returns an error that shows the invalid option
func InvalidOptionf ¶
InvalidOptionf returns an error that shows the invalid option
func IsValidUrl ¶ added in v2.1.56
IsValidUrl tests a string to determine if it is a well-structured url or not.
func IsZeroOfUnderlyingType ¶
func IsZeroOfUnderlyingType(x interface{}) bool
IsZeroOfUnderlyingType checks if the underlying type of the interface is set to it's zero value
func JXBinLocation ¶
JXBinLocation finds the JX config directory and creates a bin directory inside it if it does not already exist. Returns the JX bin path
func JXBinaryLocation ¶
JXBinaryLocation Returns the path to the currently installed JX binary.
func KeyValuesToMap ¶
KeyValuesToMap converts the set of values of the form "foo=abc" into a map
func KillProcesses ¶
func KillProcessesTree ¶
func ListDirectory ¶
ListDirectory logs the directory at path
func LoadCacheData ¶
func LoadCacheData(fileName string, loader CacheLoader) ([]byte, error)
LoadCacheData loads cached data from the given cache file name and loader
func LocalFileSystemSecretsDir ¶
LocalFileSystemSecretsDir returns the default local file system secrets location for the file system alternative to vault
func MapToKeyValues ¶
MapToKeyValues converts the the map into a sorted array of key/value pairs
func MapToString ¶
MapToString converts the map to a string
func MarkdownLink ¶
MarkdownLink returns a markdown link
func MavenBinaryLocation ¶
func MergeMaps ¶
MergeMaps merges all the maps together with the entries in the last map overwriting any earlier values
so if you want to add some annotations to a resource you can do resource.Annotations = kube.MergeMaps(resource.Annotations, myAnnotations)
func MissingArgument ¶
MissingArgument reports a missing command line argument name
func MissingEnv ¶
MissingEnv reports a missing environment variable
func MissingOption ¶
MissingOption reports a missing command line option using the full name expression
func MissingOptionWithOptions ¶
MissingOptionWithOptions reports a missing command line option using the full name expression along with a list of available values
func OrganisationsDir ¶
func PathWithBinary ¶
PathWithBinary Returns the path to be used to execute a binary from, takes the form JX_HOME/bin:mvnBinDir:customPaths
func PickNameWithDefault ¶
func PickNameWithDefault(names []string, message string, defaultValue string, help string, handles IOFileHandles) (string, error)
PickNameWithDefault gets the user to pick an option from a list of options, with a default option specified
func PickNames ¶
func PickNames(names []string, message string, help string, handles IOFileHandles) ([]string, error)
PickNames gets the user to pick multiple selections from a list of options
func PickNamesWithDefaults ¶
func PickNamesWithDefaults(names []string, defaults []string, message string, help string, handles IOFileHandles) ([]string, error)
PickNamesWithDefaults gets the user to pick multiple selections from a list of options with a set of default selections
func PickPassword ¶
func PickPassword(message string, help string, handles IOFileHandles) (string, error)
PickPassword gets a password (via hidden input) from a user's free-form input
func PickRequiredNameWithDefault ¶
func PickRequiredNameWithDefault(names []string, message string, defaultValue string, help string, handles IOFileHandles) (string, error)
PickRequiredNameWithDefault gets the user to pick an option from a list of options, with a default option specified
func PickValue ¶
func PickValue(message string, defaultValue string, required bool, help string, handles IOFileHandles) (string, error)
PickValue gets an answer to a prompt from a user's free-form input
func PluginBinDir ¶
PluginBinDir returns the plugin bin directory for the given ns
func PomFlavour ¶
func PrettyPrint ¶
func PrettyPrint(i interface{}) string
PrettyPrint returns an indented string representation of the passed struct for the purpose of logging/debugging.
func QuestionAnswer ¶
QuestionAnswer returns strings like Cobra question/answers for default cli options
func RandStringBytesMaskImprSrc ¶
RandStringBytesMaskImprSrc returns a random hexadecimal string of length n.
func RecreateDirs ¶
DeleteDirContents removes all the contents of the given directory
func RegexpSplit ¶
RegexpSplit splits a string into an array using the regexSep as a separator
func RemoveStringFromSlice ¶
RemoveStringFromSlice removes the first occurrence of the specified string from a slice, if it exists and returns the result
func RenameFile ¶
func ReplaceAllStringSubmatchFunc ¶
func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func(groups []Group) []string) string
ReplaceAllStringSubmatchFunc will replace all the submatches found in str by re by calling repl and replacing each submatch with the result. Both the argument and the result of repl ignore the entire match (i.e. the item at index 0 is the first submatch)
func RestoreEnviron ¶
RestoreEnviron sets the in the environment the environment variables provided as input
func RetryWithInitialDelay ¶
RetryWithInitialDelay retires with exponential backoff and initial delay the given function
func RetryWithInitialDelaySlower ¶
RetryWithInitialDelaySlower retries with exponential backoff, an initial delay and with a slower rate
func ReverseStrings ¶
func ReverseStrings(a []string)
func RunCommandBackground ¶
func SanitizeLabel ¶
SanitizeLabel returns a label with disallowed characters removed
func SanitizeURL ¶
SanitizeURL sanitizes by stripping the user and password
func SelectNames ¶
func SelectNames(names []string, message string, selectAll bool, help string, handles IOFileHandles) ([]string, error)
SelectNames select which names from the list should be chosen
func SelectNamesWithFilter ¶
func SelectNamesWithFilter(names []string, message string, selectAll bool, filter string, help string, handles IOFileHandles) ([]string, error)
SelectNamesWithFilter selects from a list of names with a given filter. Optionally selecting them all
func SetMapValueViaPath ¶
SetMapValueViaPath sets the map key using the given path which supports the form `foo.bar.whatnot` to mean `m["foo"]["bar"]["whatnot"]` lazily creating maps as the path is navigated
func SortedMapKeys ¶
SortedMapKeys returns the sorted keys of the given map
func StartsWith ¶
StartsWith returns true if the string starts with the given substring
func StringArrayHasPrefixIndex ¶
StringArrayHasPrefixIndex returns the index in the slice which the value has the given prefix
func StringArrayIndex ¶
StringArrayIndex returns the index in the slice which equals the given value
func StringArrayToLower ¶
StringArrayToLower returns a string slice with all the values converted to lower case
func StringArraysEqual ¶
StringArraysEqual returns true if the two string slices are equal
func StringContainsAny ¶
StringContainsAny returns true if the given text contains the includes/excludes lists
func StringIndexes ¶
StringIndexes returns all the indices where the value occurs in the given string
func StringMapHasValue ¶
StringMapHasValue returns true if the given map contains the given value
func StringMatchesAny ¶
StringMatchesAny returns true if the given text matches the includes/excludes lists
func StringMatchesPattern ¶
StringMatchesPattern returns true if the given text matches the includes/excludes lists
func StringsContaining ¶
StringsContaining if the filter is not empty return all the strings which contain the text
func StripTrailingSlash ¶
StripTrailingSlash removes any trailing forward slashes on the URL
func SuggestionsFor ¶
func ToCamelCase ¶
ToCamelCase turn "my-super-name" into "MySuperName" Usefule for creating valid go-template variable names
func ToMapStringInterfaceFromStruct ¶
ToMapStringInterfaceFromStruct marshals a struct to a generic map[string]interface{} by marshalling it to json and back Use JSON for the marshalling instead of YAML because sub-structs will get marshalled into map[interface{}]interface{} when using YAML, but map[string]interface{} when using JSON and vault libraries can't handle map[interface{}]interface{}
func ToObjectMap ¶
ToObjectMap converts the given object into a map of strings/maps using YAML marshalling
func ToStringMapStringFromStruct ¶
ToStringMapStringFromStruct returns string[map]string from any struct. Use structs tag to change map keys. e.g. ServerName string `structs:"server_name"`
func ToStructFromMapStringInterface ¶
ToStructFromMapStringInterface marshals a generic map[string]interface{} to a struct by marshalling to json and back Use JSON for the marshalling instead of YAML because sub-structs will get marshalled into map[interface{}]interface{} when using YAML, but map[string]interface{} when using JSON and vault libraries can't handle map[interface{}]interface{}
func ToValidFileSystemName ¶
ToValidFileSystemName converts the name to one that can safely be used on the filesystem
func URLToHostName ¶
URLToHostName converts the given URL to a host name returning the error string if its not a URL
func UnTargz ¶
untargz a tarball to a target, from http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzipf
func UnTargzAll ¶
untargz a tarball to a target including any folders inside the tarball http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzipf
func Unzip ¶
Unzips the archvie into the specified directory returns an error if a general issue occurred unzipping the archive
func UnzipSpecificFiles ¶
Unzips the specified files from the archive returns an error if any of the specified files are not found or a general issue occurred unzipping the archive
func UrlHostNameWithoutPort ¶
UrlHostNameWithoutPort returns the host name without any port of the given URL like string
func UrlJoin ¶
UrlJoin joins the given paths so that there is only ever one '/' character between the paths
func ValidateYaml ¶
ValidateYaml generates a JSON schema for the given struct type, and then validates the given YAML against that schema, ignoring Containers and missing fields.
func WriteJenkinsfileStatements ¶
WriteJenkinsfileStatements writes the given Jenkinsfile statements as a string
Types ¶
type CacheLoader ¶
CacheLoader defines cache value population callback that should be executed if cache entry with given key is not present.
type Command ¶
type Command struct { Errors []error Dir string Name string Args []string ExponentialBackOff *backoff.ExponentialBackOff Timeout time.Duration Out io.Writer Err io.Writer In io.Reader Env map[string]string // contains filtered or unexported fields }
Command is a struct containing the details of an external command to be executed
func (*Command) CurrentArgs ¶
CurrentArgs returns the current command arguments
func (*Command) CurrentDir ¶
CurrentDir returns the current Dir
func (*Command) CurrentEnv ¶
CurrentEnv returns the current environment variables
func (*Command) CurrentName ¶
CurrentName returns the current name of the command
func (*Command) DidError ¶
DidError returns a boolean if any error occurred in any execution of the command
func (*Command) DidFail ¶
DidFail returns a boolean if the command could not complete (errored on every attempt)
func (*Command) RunWithoutRetry ¶
RunWithoutRetry Execute the command without retrying on failure and block waiting for return values
func (*Command) SetArgs ¶
SetArgs Setter method for Args to enable use of interface instead of Command struct
func (*Command) SetDir ¶
SetDir Setter method for Dir to enable use of interface instead of Command struct
func (*Command) SetEnv ¶
SetEnv Setter method for Env to enable use of interface instead of Command struct
func (*Command) SetEnvVariable ¶
SetEnvVariable sets an environment variable into the environment
func (*Command) SetExponentialBackOff ¶
func (c *Command) SetExponentialBackOff(backoff *backoff.ExponentialBackOff)
SetExponentialBackOff Setter method for ExponentialBackOff to enable use of interface instead of Command struct
func (*Command) SetName ¶
SetName Setter method for Name to enable use of interface instead of Command struct
func (*Command) SetTimeout ¶
SetTimeout Setter method for Timeout to enable use of interface instead of Command struct
type CommandError ¶
type CommandError struct { Command Command Output string // contains filtered or unexported fields }
CommandError is the error object encapsulating an error from a Command
func (CommandError) Cause ¶
func (c CommandError) Cause() error
func (CommandError) Error ¶
func (c CommandError) Error() string
type Commander ¶
type Commander interface { DidError() bool DidFail() bool Error() error Run() (string, error) RunWithoutRetry() (string, error) SetName(string) CurrentName() string SetDir(string) CurrentDir() string SetArgs([]string) CurrentArgs() []string SetTimeout(time.Duration) SetExponentialBackOff(*backoff.ExponentialBackOff) SetEnv(map[string]string) CurrentEnv() map[string]string SetEnvVariable(string, string) }
Commander defines the interface for a Command
type IOFileHandles ¶
type IOFileHandles struct { Err io.Writer In terminal.FileReader Out terminal.FileWriter }
IOFileHandles is a struct for holding CommonOptions' In, Out, and Err I/O handles, to simplify function calls.
type Statement ¶
Statement represents a statement in a Jenkinsfile
func (*Statement) ContextEquals ¶
ContextEquals returns true if this statement is a context statement and it equals the same context as that statement
Source Files ¶
- auth.go
- cache.go
- color.go
- commands.go
- constants.go
- date.go
- dirs.go
- downloads.go
- environ.go
- files.go
- http_utils.go
- interface.go
- jenkinsfile_writer.go
- k8s.go
- maps.go
- markdown.go
- numbers.go
- padding.go
- pickers.go
- pom_flavour.go
- process.go
- regex.go
- retry.go
- shell.go
- strings.go
- structs.go
- suggestions.go
- test.go
- types.go
- unzip.go
- urls.go
- validation.go