utils

package
v2.57.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 44 Imported by: 21

Documentation

Index

Constants

View Source
const (
	// DefaultThreads is the default number of threads working while transferring Artifactory's data
	DefaultThreads = 8
	// Maximum working threads allowed to execute the AQL queries and upload chunks for build-info repositories
	MaxBuildInfoThreads = 8
	// Maximum working threads allowed to execute the AQL queries
	MaxChunkBuilderThreads = 16
)

Variables

View Source
var RepoTypes = []string{
	"local",
	"remote",
	"virtual",
	"federated",
}

Functions

func AqlResultToSearchResult

func AqlResultToSearchResult(readers []*content.ContentReader) (contentReader *content.ContentReader, err error)

func ConfirmDelete

func ConfirmDelete(pathsToDeleteReader *content.ContentReader) (bool, error)

func CreateAccessServiceManager added in v2.2.0

func CreateAccessServiceManager(serviceDetails *config.ServerDetails, isDryRun bool) (*access.AccessServicesManager, error)

func CreateDeleteServiceManager

func CreateDeleteServiceManager(artDetails *config.ServerDetails, threads, httpRetries, httpRetryWaitMilliSecs int, dryRun bool) (artifactory.ArtifactoryServicesManager, error)

func CreateDistributionServiceManager

func CreateDistributionServiceManager(serviceDetails *config.ServerDetails, isDryRun bool) (*distribution.DistributionServicesManager, error)

func CreateDownloadServiceManager

func CreateDownloadServiceManager(artDetails *config.ServerDetails, threads, httpRetries, httpRetryWaitMilliSecs int, dryRun bool, progressBar io.ProgressMgr) (artifactory.ArtifactoryServicesManager, error)

func CreateEvidenceServiceManager added in v2.53.1

func CreateEvidenceServiceManager(serviceDetails *config.ServerDetails, isDryRun bool) (*evidence.EvidenceServicesManager, error)

func CreateLifecycleServiceManager added in v2.37.0

func CreateLifecycleServiceManager(serviceDetails *config.ServerDetails, isDryRun bool) (*lifecycle.LifecycleServicesManager, error)

func CreateMetadataServiceManager added in v2.55.0

func CreateMetadataServiceManager(serviceDetails *config.ServerDetails, isDryRun bool) (metadata.Manager, error)

func CreateServiceManager

func CreateServiceManager(serverDetails *config.ServerDetails, httpRetries, httpRetryWaitMilliSecs int, isDryRun bool) (artifactory.ArtifactoryServicesManager, error)

func CreateServiceManagerWithContext added in v2.20.6

func CreateServiceManagerWithContext(context context.Context, serverDetails *config.ServerDetails, isDryRun bool, threads, httpRetries, httpRetryWaitMilliSecs int, timeout time.Duration) (artifactory.ArtifactoryServicesManager, error)

func CreateServiceManagerWithProgressBar

func CreateServiceManagerWithProgressBar(serverDetails *config.ServerDetails, threads, httpRetries, httpRetryWaitMilliSecs int, dryRun bool, progressBar ioUtils.ProgressMgr) (artifactory.ArtifactoryServicesManager, error)

func CreateServiceManagerWithThreads

func CreateServiceManagerWithThreads(serverDetails *config.ServerDetails, isDryRun bool, threads, httpRetries, httpRetryWaitMilliSecs int) (artifactory.ArtifactoryServicesManager, error)

Create a service manager with threads. If the value sent for httpRetries is negative, the default will be used.

func CreateUploadServiceManager

func CreateUploadServiceManager(serverDetails *config.ServerDetails, threads, httpRetries, httpRetryWaitMilliSecs int, dryRun bool, progressBar io.ProgressMgr) (artifactory.ArtifactoryServicesManager, error)

func DoWebLogin added in v2.38.0

func DoWebLogin(serverDetails *config.ServerDetails) (token auth.CommonTokenParams, err error)

func GetBuildScanError

func GetBuildScanError() error

func GetEncryptedPasswordFromArtifactory

func GetEncryptedPasswordFromArtifactory(artifactoryAuth auth.ServiceDetails, insecureTls bool) (string, error)

func GetFilesCountFromRepositorySummary added in v2.24.0

func GetFilesCountFromRepositorySummary(repoSummary *utils.RepositorySummary) (int64, error)

func GetFilteredBuildInfoRepositories added in v2.19.1

func GetFilteredBuildInfoRepositories(storageInfo *clientUtils.StorageInfo, includePatterns, excludePatterns []string) ([]string, error)

GetFilteredBuildInfoRepositories returns the names of all build-info repositories filtered by their names. storageInfo - storage info response from Artifactory includePatterns - patterns of repository names (can contain wildcards) to include in the results. A repository's name must match at least one of these patterns in order to be included in the results. If includePatterns' length is zero, all repositories are included. excludePatterns - patterns of repository names (can contain wildcards) to exclude from the results. A repository's name must NOT match any of these patterns in order to be included in the results.

func GetFilteredRepositoriesWithFilterParams added in v2.56.3

func GetFilteredRepositoriesWithFilterParams(servicesManager artifactory.ArtifactoryServicesManager, includePatterns, excludePatterns []string, filterParams services.RepositoriesFilterParams) ([]string, error)

GetFilteredRepositoriesWithFilterParams returns the names of local, remote, virtual, and federated repositories filtered by their names and type. servicesManager - The Artifactory services manager used to interact with the Artifactory server. includePatterns - Patterns of repository names (can contain wildcards) to include in the results. A repository's name must match at least one of these patterns in order to be included in the results. If includePatterns' length is zero, all repositories are included. excludePatterns - Patterns of repository names (can contain wildcards) to exclude from the results. A repository's name must NOT match any of these patterns in order to be included in the results. filterParams - Parameters to filter the repositories by their type. Returns a slice of repository names that match the given patterns and type, or an error if the operation fails.

func GetMinChecksumDeploySize added in v2.49.0

func GetMinChecksumDeploySize() (int64, error)

func GetProjectDir

func GetProjectDir(global bool) (string, error)

func GetRepoNameForDependenciesSearch

func GetRepoNameForDependenciesSearch(repoName string, serviceManager artifactory.ArtifactoryServicesManager) (string, error)

Since we can't search dependencies in a remote repository, we will turn the search to the repository's cache. Local/Virtual repository name will be returned as is.

func GetRtMajorVersion added in v2.54.0

func GetRtMajorVersion(servicesManager artifactory.ArtifactoryServicesManager) (int, error)

func GetSearchParams

func GetSearchParams(f *spec.File) (searchParams services.SearchParams, err error)

func GetTestDataPath added in v2.10.0

func GetTestDataPath() (string, error)

func GetUsedSpaceInBytes added in v2.23.2

func GetUsedSpaceInBytes(repoSummary *utils.RepositorySummary) (int64, error)

func IsRemoteRepo

func IsRemoteRepo(repoName string, serviceManager artifactory.ArtifactoryServicesManager) (bool, error)

func PrintSearchResults

func PrintSearchResults(reader *content.ContentReader) error

func RemoteUnmarshal

func RemoteUnmarshal(serviceManager artifactory.ArtifactoryServicesManager, remoteFileUrl string, loadTarget interface{}) (err error)

Download and unmarshal a file from artifactory.

func SaveTransferSettings added in v2.17.0

func SaveTransferSettings(settings *TransferSettings) (err error)

func SearchFiles added in v2.49.0

func SearchFiles(servicesManager artifactory.ArtifactoryServicesManager, spec *spec.SpecFiles) (searchResults []*content.ContentReader, callbackFunc func() error, err error)

func SearchResultNoDate

func SearchResultNoDate(reader *content.ContentReader) (contentReader *content.ContentReader, err error)

func SelectRepositoryInteractively added in v2.57.0

func SelectRepositoryInteractively(serverDetails *config.ServerDetails, repoFilterParams services.RepositoriesFilterParams) (string, error)

SelectRepositoryInteractively prompts the user to select a repository from a list of repositories that match the given filter parameters.

func ValidateRepoExists added in v2.9.0

func ValidateRepoExists(repoKey string, serviceDetails auth.ServiceDetails) error

Returns an error if the given repo doesn't exist.

Types

type DownloadConfiguration

type DownloadConfiguration struct {
	Threads    int
	SplitCount int
	// Min split size in Kilobytes
	MinSplitSize    int64
	Symlink         bool
	ValidateSymlink bool
	SkipChecksum    bool
}

type FileTree added in v2.17.0

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

FileTree is a UI components that displays a file-system tree view in the terminal.

func NewFileTree added in v2.17.0

func NewFileTree() *FileTree

func (*FileTree) AddFile added in v2.17.0

func (ft *FileTree) AddFile(path, uploadedFileUrl string)

Path - file structure path to artifact UploadedFileUrl - URL to the uploaded file in Artifactory, if UploadedFileUrl not provided, the file name will be displayed without a link.

func (*FileTree) IsTreeExceedsMax added in v2.56.3

func (ft *FileTree) IsTreeExceedsMax() bool

func (*FileTree) String added in v2.17.0

func (ft *FileTree) String() string

Returns a string representation of the tree. If the number of files exceeded the maximum, an empty string will be returned.

type IncludeExcludeFilter added in v2.28.0

type IncludeExcludeFilter struct {
	IncludePatterns []string
	ExcludePatterns []string
}

func (*IncludeExcludeFilter) ShouldIncludeItem added in v2.28.0

func (ief *IncludeExcludeFilter) ShouldIncludeItem(item string) (bool, error)

func (*IncludeExcludeFilter) ShouldIncludeRepository added in v2.28.0

func (ief *IncludeExcludeFilter) ShouldIncludeRepository(repoKey string) (bool, error)

type RepoType

type RepoType int
const (
	Local RepoType = iota
	Remote
	Virtual
	Federated
	Unknown
)

func RepoTypeFromString added in v2.29.8

func RepoTypeFromString(repoTypeStr string) RepoType

func (RepoType) String

func (repoType RepoType) String() string

type SearchResult

type SearchResult struct {
	Path         string              `json:"path,omitempty"`
	Type         string              `json:"type,omitempty"`
	Size         int64               `json:"size,omitempty"`
	Created      string              `json:"created,omitempty"`
	Modified     string              `json:"modified,omitempty"`
	Sha1         string              `json:"sha1,omitempty"`
	Sha256       string              `json:"sha256,omitempty"`
	Md5          string              `json:"md5,omitempty"`
	OriginalMd5  string              `json:"original_md5,omitempty"`
	ModifiedBy   string              `json:"modified_by,omitempty"`
	Updated      string              `json:"updated,omitempty"`
	CreatedBy    string              `json:"created_by,omitempty"`
	OriginalSha1 string              `json:"original_sha1,omitempty"`
	Depth        int                 `json:"depth,omitempty"`
	Props        map[string][]string `json:"props,omitempty"`
}

type StorageInfoManager added in v2.20.0

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

func NewStorageInfoManager added in v2.20.0

func NewStorageInfoManager(ctx context.Context, serverDetails *config.ServerDetails) (*StorageInfoManager, error)

func (*StorageInfoManager) CalculateStorageInfo added in v2.20.0

func (sim *StorageInfoManager) CalculateStorageInfo() error

Start calculating storage info in Artifactory

func (*StorageInfoManager) GetRepoSummary added in v2.20.0

func (sim *StorageInfoManager) GetRepoSummary(repoKey string) (*utils.RepositorySummary, error)

Get repository summary from the storage info. This method must be called after CalculateStorageInfo. repoKey - The repository key

func (*StorageInfoManager) GetReposTotalSizeAndFiles added in v2.24.0

func (sim *StorageInfoManager) GetReposTotalSizeAndFiles(repoKeys ...string) (totalSize, totalFiles int64, err error)

GetReposTotalSizeAndFiles gets the total size (bytes) and files of all passed repositories. This method must be called after CalculateStorageInfo. The result of this function might not be accurate!

func (*StorageInfoManager) GetServiceId added in v2.21.0

func (sim *StorageInfoManager) GetServiceId() (string, error)

Get Service Id from Artifactory

func (*StorageInfoManager) GetServiceManager added in v2.21.0

func (*StorageInfoManager) GetStorageInfo added in v2.20.0

func (sim *StorageInfoManager) GetStorageInfo() (*utils.StorageInfo, error)

Get storage info from Artifactory

type TransferSettings added in v2.17.0

type TransferSettings struct {
	ThreadsNumber int `json:"threadsNumber,omitempty"`
}

func LoadTransferSettings added in v2.17.0

func LoadTransferSettings() (settings *TransferSettings, err error)

func (*TransferSettings) CalcNumberOfThreads added in v2.19.2

func (ts *TransferSettings) CalcNumberOfThreads(buildInfoRepo bool) (chunkBuilderThreads, chunkUploaderThreads int)

type UploadConfiguration

type UploadConfiguration struct {
	Deb                   string
	Threads               int
	MinChecksumDeploySize int64
	ExplodeArchive        bool
	SplitCount            int
	MinSplitSizeMB        int64
	ChunkSizeMB           int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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