utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: Apache-2.0 Imports: 17 Imported by: 137

Documentation

Index

Constants

View Source
const (
	Development = "development"
	Agent       = "jfrog-client-go"
	Version     = "0.6.0"
)
View Source
const CredentialsInUrlRegexp = `((http|https):\/\/[%|\w]+:[%|\w]+@)`
View Source
const MAX_ENTRIES = 10000

Variables

This section is empty.

Functions

func AddEscapingParentheses added in v0.5.3

func AddEscapingParentheses(pattern, target string) string

Escapoing Parentheses with no corresponding placeholder

func AddTrailingSlashIfNeeded

func AddTrailingSlashIfNeeded(url string) string

func Bool2Int

func Bool2Int(b bool) int

func BuildTargetPath

func BuildTargetPath(pattern, path, target string, ignoreRepo bool) (string, error)

Replaces matched regular expression from path to corresponding {i} at target. Example 1:

pattern = "repoA/1(.*)234" ; path = "repoA/1hello234" ; target = "{1}" ; ignoreRepo = false
returns "hello"

Example 2:

pattern = "repoA/1(.*)234" ; path = "repoB/1hello234" ; target = "{1}" ; ignoreRepo = true
returns "hello"

func CheckErrorWithMessage added in v0.1.1

func CheckErrorWithMessage(err error, message string) error

func ConvertSliceToMap added in v0.1.2

func ConvertSliceToMap(slice []string) map[string]bool

func CopyMap

func CopyMap(src map[string]string) (dst map[string]string)

func GetBoolEnvValue added in v0.1.1

func GetBoolEnvValue(flagName string, defValue bool) (bool, error)

func GetLogMsgPrefix

func GetLogMsgPrefix(threadId int, dryRun bool) string

func GetRegExp added in v0.3.1

func GetRegExp(regex string) (*regexp.Regexp, error)

func GetRootPath

func GetRootPath(path string, useRegExp bool) string

Get the local root path, from which to start collecting artifacts to be used for: 1. Uploaded to Artifactory, 2. Adding to the local build-info, to be later published to Artifactory.

func GetUserAgent

func GetUserAgent() string

func GetUserHomeDir

func GetUserHomeDir() string

func IndentJson

func IndentJson(jsonStr []byte) string

func IsWindows

func IsWindows() bool

func MaskCredentials added in v0.3.1

func MaskCredentials(completeUrl, credentialsPart string) string

Mask the credentials information from the completeUrl, contained in credentialsPart. The credentials are built as user:password For example: completeUrl = http://user:password@127.0.0.1:8081/artifactory/path/to/repo credentialsPart = http://user:password@ Returned value: http://***:***@127.0.0.1:8081/artifactory/path/to/repo

func MergeMaps

func MergeMaps(src map[string]string, dst map[string]string)

func PrepareLocalPathForUpload

func PrepareLocalPathForUpload(localPath string, useRegExp bool) string

func RemovePlaceholderParentheses added in v0.5.3

func RemovePlaceholderParentheses(pattern, target string) string

func ReplaceTildeWithUserHome

func ReplaceTildeWithUserHome(path string) string

func SetUserAgent

func SetUserAgent(newUserAgent string)

func SplitWithEscape

func SplitWithEscape(str string, separator rune) []string

Split str by the provided separator, escaping the separator if it is prefixed by a back-slash.

func StringToBool

func StringToBool(boolVal string, defaultValue bool) (bool, error)

func TrimPath

func TrimPath(path string) string

Types

type Artifact

type Artifact struct {
	LocalPath  string
	TargetPath string
	Symlink    string
}

type ExecutionHandlerFunc added in v0.2.2

type ExecutionHandlerFunc func() (bool, error)

type Parentheses added in v0.5.3

type Parentheses struct {
	OpenIndex  int
	CloseIndex int
}

This struct represents the parentheses used for defining Placeholders (Placeholders is a feature supported by File Specs).

type ParenthesesSlice added in v0.5.3

type ParenthesesSlice struct {
	Parentheses []Parentheses
}

func (*ParenthesesSlice) IsPresent added in v0.5.3

func (p *ParenthesesSlice) IsPresent(index int) bool

type RetryExecutor added in v0.2.2

type RetryExecutor struct {
	// The amount of retries to perform.
	MaxRetries int

	// Number of seconds to sleep between retries.
	RetriesInterval int

	// Message to display when retrying.
	ErrorMessage string

	// Prefix to print at the beginning of each log.
	LogMsgPrefix string

	// ExecutionHandler is the operation to run with retries.
	ExecutionHandler ExecutionHandlerFunc
}

func (*RetryExecutor) Execute added in v0.2.2

func (runner *RetryExecutor) Execute() error

type VcsDetails added in v0.6.0

type VcsDetails struct {
	// contains filtered or unexported fields
}

func NewVcsDetals added in v0.6.0

func NewVcsDetals() *VcsDetails

func (*VcsDetails) GetVcsData added in v0.6.0

func (this *VcsDetails) GetVcsData(path string) (revision, refUrl string, err error)

Start search for '.git' dir for the current path, incase there is one, extract the details and add a new entry to the cache(hash-map,key:path,value:pointer to the git details). otherwise, search in the parent folder and try: 1. search for .git, and save the details for the current dir and all subpath 2. .git not found, go to parent dir and repeat 3. not found on the root directory, add all subpath to cache with nil as a value

Jump to

Keyboard shortcuts

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