Documentation ¶
Index ¶
- Constants
- Variables
- func AddEscapingParentheses(pattern, target, targetPathInArchive string) string
- func AddProps(oldProps, additionalProps string) string
- func AddTrailingSlashIfNeeded(url string) string
- func AntToRegex(antPattern string) string
- func Bool2Int(b bool) int
- func BuildTargetPath(pattern, path, target string, ignoreRepo bool) (string, bool, error)
- func BuildUrl(baseUrl, path string, params map[string]string) (string, error)
- func CheckErrorWithMessage(err error, message string) error
- func ConvertLocalPatternToRegexp(localPath string, patternType PatternType) string
- func ConvertSliceToMap(slice []string) map[string]bool
- func CopyMap(src map[string]string) (dst map[string]string)
- func ExtractArchive(localPath, localFileName, originFileName, logMsgPrefix string, ...) error
- func ExtractSha256FromResponseBody(body []byte) (string, error)
- func GetBoolEnvValue(flagName string, defValue bool) (bool, error)
- func GetLogMsgPrefix(threadId int, dryRun bool) string
- func GetRegExp(regex string) (*regexp.Regexp, error)
- func GetRootPath(path string, patternType PatternType, parentheses ParenthesesSlice) string
- func GetUserAgent() string
- func GetUserHomeDir() string
- func IndentJson(jsonStr []byte) string
- func IndentJsonArray(jsonStr []byte) string
- func IsPlaceholdersUsed(pattern, target string) bool
- func IsSlashPrecedeAsterisk(asteriskIndex, slashIndex int) bool
- func MergeMaps(src map[string]string, dst map[string]string)
- func Pointer[K any](val K) *K
- func RemoveCredentials(line, credentialsPart string) string
- func RemovePlaceholderParentheses(pattern, target string) string
- func ReplacePlaceHolders(groups []string, toReplace string, isRegexp bool) (string, bool, error)
- func ReplaceTildeWithUserHome(path string) string
- func SaveFileTransferDetailsInFile(filePath string, details *[]FileTransferDetails) error
- func SaveFileTransferDetailsInTempFile(filesDetails *[]FileTransferDetails) (filePath string, err error)
- func SetUserAgent(newUserAgent string)
- func SplitWithEscape(str string, separator rune) []string
- func StringToBool(boolVal string, defaultValue bool) (bool, error)
- func TrimPath(path string) string
- func ValidateMinimumVersion(product MinVersionProduct, currentVersion, minimumVersion string) error
- type Artifact
- type DeployableArtifactDetails
- type ErrorsQueue
- type ExecutionHandlerFunc
- type FileTransferDetails
- type GitManager
- type MinVersionProduct
- type Parentheses
- type ParenthesesSlice
- type PatternType
- type PatternTypes
- type RetryExecutor
- type RetryExecutorTimeoutError
- type Sha256Summary
- type UploadResponseBody
- type VcsCache
Constants ¶
const ( Development = "development" Agent = "jfrog-client-go" Version = "1.36.1" )
const CredentialsInUrlRegexp = `(http|https|git)://.+@`
#nosec G101 -- False positive - no hardcoded credentials.
const MaxEntries = 10000
Variables ¶
var (
MaxBufferSize = 50000
)
In order to limit the number of items loaded from a reader into the memory, we use a buffers with this size limit.
Functions ¶
func AddEscapingParentheses ¶ added in v0.5.3
AddEscapingParentheses escapes parentheses with no corresponding placeholder. pattern - the pattern in which the parentheses are escaped. target - target parameter containing placeholders. targetPathInArchive - The target archive path containing placeholders (relevant only for upload commands).
func AntToRegex ¶ added in v1.28.0
func BuildTargetPath ¶
BuildTargetPath Replaces matched regular expression from path to corresponding placeholder {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"
return (parsed target, placeholders replaced in target, error)
func BuildUrl ¶ added in v1.31.6
Builds a URL for Artifactory/Xray requests. Pay attention: semicolons are escaped!
func CheckErrorWithMessage ¶ added in v0.1.1
func ConvertLocalPatternToRegexp ¶ added in v1.0.1
func ConvertLocalPatternToRegexp(localPath string, patternType PatternType) string
func ConvertSliceToMap ¶ added in v0.1.2
func ExtractArchive ¶ added in v0.17.2
func ExtractArchive(localPath, localFileName, originFileName, logMsgPrefix string, bypassInspection bool) error
localPath - The path of the downloaded archive file. localFileName - The name of the archive file. originFileName - The name of the archive file in Artifactory. logMsgPrefix - A prefix to the log message. bypassInspection - Set to true to bypass archive inspection against ZipSlip Extract an archive file to the 'localPath'.
func ExtractSha256FromResponseBody ¶ added in v0.24.0
Extract sha256 of the uploaded file (calculated by artifactory) from the response's body. In case of uploading archive with "--explode" the response body will be empty and sha256 won't be shown at the detailed summary.
func GetBoolEnvValue ¶ added in v0.1.1
func GetLogMsgPrefix ¶
func GetRootPath ¶
func GetRootPath(path string, patternType PatternType, parentheses ParenthesesSlice) 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 IndentJsonArray ¶ added in v0.13.0
func IsPlaceholdersUsed ¶ added in v1.15.0
Return true if at least one of the {i} in 'target' has corresponding parentheses in 'pattern'.
func IsSlashPrecedeAsterisk ¶ added in v0.11.1
func Pointer ¶ added in v1.33.0
func Pointer[K any](val K) *K
Convert any value to a pointer to that value
func RemoveCredentials ¶ added in v0.17.5
Remove credentials from the URL contained in the input line. The credentials are built as 'user:password' or 'token' For example: line = 'This is a line http://user:password@127.0.0.1:8081/artifactory/path/to/repo' credentialsPart = 'http://user:password@' Returned value: 'This is a line http://127.0.0.1:8081/artifactory/path/to/repo'
line = 'This is a line http://token@127.0.0.1:8081/artifactory/path/to/repo' credentialsPart = 'http://token@' Returned value: 'This is a line http://127.0.0.1:8081/artifactory/path/to/repo'
func RemovePlaceholderParentheses ¶ added in v0.5.3
func ReplacePlaceHolders ¶ added in v1.0.1
ReplacePlaceHolders replace placeholders with their matching regular expressions. group - Regular expression matched group to replace with placeholders. toReplace - Target pattern to replace. isRegexp - When using a regular expression, all parentheses content in the target will be at the given group parameter. A non-regular expression will, however, allow us to consider the parentheses as literal characters. The size of the group (containing the parentheses content) can be smaller than the maximum placeholder indexer - in this case, special treatment is required. Example : pattern: (a)/(b)/(c), target: "target/{1}{3}" => '(a)' and '(c)' will be considered as placeholders, and '(b)' will be treated as the directory's actual name. In this case, the index of '(c)' in the group is 2, but its placeholder indexer is 3. Return - The parsed placeholders string, along with a boolean to indicate whether they have been replaced or not.
func SaveFileTransferDetailsInFile ¶ added in v0.24.0
func SaveFileTransferDetailsInFile(filePath string, details *[]FileTransferDetails) error
func SaveFileTransferDetailsInTempFile ¶ added in v0.24.0
func SaveFileTransferDetailsInTempFile(filesDetails *[]FileTransferDetails) (filePath string, err error)
func SetUserAgent ¶
func SetUserAgent(newUserAgent string)
func SplitWithEscape ¶
Split str by the provided separator, escaping the separator if it is prefixed by a back-slash.
func ValidateMinimumVersion ¶ added in v1.31.6
func ValidateMinimumVersion(product MinVersionProduct, currentVersion, minimumVersion string) error
Types ¶
type DeployableArtifactDetails ¶ added in v0.24.0
type DeployableArtifactDetails struct { SourcePath string `json:"sourcePath,omitempty"` ArtifactDest string `json:"artifactDest,omitempty"` Sha256 string `json:"sha256,omitempty"` DeploySucceeded bool `json:"deploySucceeded,omitempty"` TargetRepository string `json:"targetRepository,omitempty"` }
Represent deployed artifact's details returned from build-info project for maven and gradle.
func (*DeployableArtifactDetails) CreateFileTransferDetails ¶ added in v0.24.0
func (details *DeployableArtifactDetails) CreateFileTransferDetails(rtUrl, targetRepository string) (FileTransferDetails, error)
type ErrorsQueue ¶ added in v0.11.0
type ErrorsQueue struct {
// contains filtered or unexported fields
}
func NewErrorsQueue ¶ added in v0.11.0
func NewErrorsQueue(size int) *ErrorsQueue
func (*ErrorsQueue) AddError ¶ added in v0.11.0
func (errQueue *ErrorsQueue) AddError(err error)
func (*ErrorsQueue) GetError ¶ added in v0.11.0
func (errQueue *ErrorsQueue) GetError() error
type ExecutionHandlerFunc ¶ added in v0.2.2
type FileTransferDetails ¶ added in v0.24.0
type FileTransferDetails struct { SourcePath string `json:"sourcePath,omitempty"` TargetPath string `json:"targetPath,omitempty"` RtUrl string `json:"rtUrl,omitempty"` Sha256 string `json:"sha256,omitempty"` }
Represents a file transfer from SourcePath to TargetPath. Each of the paths can be on the local machine (full or relative) or in Artifactory (without Artifactory URL). The file's Sha256 is calculated by Artifactory during the upload. we read the sha256 from the HTTP's response body.
type GitManager ¶ added in v1.13.0
type GitManager struct {
// contains filtered or unexported fields
}
func NewGitManager ¶ added in v0.6.2
func NewGitManager(path string) *GitManager
func (*GitManager) ExecGit ¶ added in v1.13.0
func (m *GitManager) ExecGit(args ...string) (string, string, error)
func (*GitManager) GetBranch ¶ added in v1.13.0
func (m *GitManager) GetBranch() string
func (*GitManager) GetMessage ¶ added in v1.13.0
func (m *GitManager) GetMessage() string
func (*GitManager) GetRevision ¶ added in v1.13.0
func (m *GitManager) GetRevision() string
func (*GitManager) GetUrl ¶ added in v1.13.0
func (m *GitManager) GetUrl() string
func (*GitManager) ReadConfig ¶ added in v1.13.0
func (m *GitManager) ReadConfig() error
type MinVersionProduct ¶ added in v1.31.6
type MinVersionProduct string
const ( Artifactory MinVersionProduct = "JFrog Artifactory" Xray MinVersionProduct = "JFrog Xray" DataTransfer MinVersionProduct = "Data Transfer" DockerApi MinVersionProduct = "Docker API" Projects MinVersionProduct = "JFrog Projects" MinimumVersionMsg = "You are using %s version %s, while this operation requires version %s or higher." )
type Parentheses ¶ added in v0.5.3
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 CreateParenthesesSlice ¶ added in v1.8.0
func CreateParenthesesSlice(pattern, target string) ParenthesesSlice
func NewParenthesesSlice ¶ added in v0.7.0
func NewParenthesesSlice(slice []Parentheses) ParenthesesSlice
func (*ParenthesesSlice) IsPresent ¶ added in v0.5.3
func (p *ParenthesesSlice) IsPresent(index int) bool
type PatternType ¶ added in v0.20.1
type PatternType string
const ( WildCardPattern PatternType = "wildcard" RegExp PatternType = "regexp" AntPattern PatternType = "ant" )
func GetPatternType ¶ added in v0.20.1
func GetPatternType(patternTypes PatternTypes) PatternType
type PatternTypes ¶ added in v0.20.1
type RetryExecutor ¶ added in v0.2.2
type RetryExecutor struct { // The context Context context.Context // The amount of retries to perform. MaxRetries int // Number of milliseconds to sleep between retries. RetriesIntervalMilliSecs 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
func (*RetryExecutor) LogRetry ¶ added in v1.8.0
func (runner *RetryExecutor) LogRetry(attemptNumber int, err error)
type RetryExecutorTimeoutError ¶ added in v1.24.2
type RetryExecutorTimeoutError struct {
// contains filtered or unexported fields
}
Error of this type will be returned if the executor reaches timeout and no other error is returned by the execution handler.
func (RetryExecutorTimeoutError) Error ¶ added in v1.24.2
func (retryErr RetryExecutorTimeoutError) Error() string
type Sha256Summary ¶ added in v0.23.0
type Sha256Summary struct {
// contains filtered or unexported fields
}
func NewSha256Summary ¶ added in v0.23.0
func NewSha256Summary() *Sha256Summary
func (*Sha256Summary) GetSha256 ¶ added in v0.23.0
func (bps *Sha256Summary) GetSha256() string
func (*Sha256Summary) IsSucceeded ¶ added in v0.23.0
func (bps *Sha256Summary) IsSucceeded() bool
func (*Sha256Summary) SetSha256 ¶ added in v0.23.0
func (bps *Sha256Summary) SetSha256(sha256 string) *Sha256Summary
func (*Sha256Summary) SetSucceeded ¶ added in v0.23.0
func (bps *Sha256Summary) SetSucceeded(succeeded bool) *Sha256Summary
type UploadResponseBody ¶ added in v0.24.0
type VcsCache ¶ added in v0.6.2
type VcsCache struct {
// contains filtered or unexported fields
}
func NewVcsDetails ¶ added in v1.7.0
func NewVcsDetails() *VcsCache
func (*VcsCache) GetVcsDetails ¶ added in v0.6.2
Search for '.git' directory inside 'path', incase there is one, extract the details and add a new entry to the cache(key:path in the file system ,value: git revision & url). 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