utils

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 Imports: 40 Imported by: 21

Documentation

Index

Constants

View Source
const (
	ProjectConfigResolverPrefix = "resolver"
	ProjectConfigDeployerPrefix = "deployer"
	ProjectConfigRepo           = "repo"
	ProjectConfigServerId       = "serverId"
)
View Source
const ArtifactPattern = "artifactPattern"
View Source
const BuildInfoDetails = "details"
View Source
const BuildName = "build.name"

For key/value binding

View Source
const BuildNumber = "build.number"
View Source
const BuildProject = "build.project"
View Source
const BuildTempPath = "jfrog/builds/"
View Source
const BuildTimestamp = "build.timestamp"
View Source
const ClassworldsConf = `` /* 166-byte string literal not displayed */
View Source
const DeployArtifacts = "artifacts"
View Source
const DeployableArtifacts = "deployable.artifacts.map"
View Source
const DeployerPrefix = "deployer."
View Source
const ExcludePatterns = "excludePatterns"
View Source
const (
	// This env var should be used for downloading the extractor jars through an Artifactory remote
	// repository, instead of downloading directly from releases.jfrog.io. The remote repository should be
	// configured to proxy releases.jfrog.io.
	// This env var should store a server ID and a remote repository in form of '<ServerID>/<RemoteRepo>'
	ExtractorsRemoteEnv = "JFROG_CLI_EXTRACTORS_REMOTE"
)
View Source
const FilterExcludedArtifactsFromBuild = "filterExcludedArtifactsFromBuild"
View Source
const ForkCount = "forkCount"
View Source
const GeneratedBuildInfo = "buildInfo.generated"
View Source
const GeneratedBuildInfoTempPrefix = "generatedBuildInfo"
View Source
const GradleInitScript = `` /* 1384-byte string literal not displayed */
View Source
const Host = "host"
View Source
const (
	HttpProxy = "HTTP_PROXY"
)
View Source
const IncludePatterns = "includePatterns"
View Source
const InsecureTls = "insecureTls"
View Source
const IvyDescriptor = "deployIvyDescriptors"
View Source
const IvyPattern = "ivyPattern"
View Source
const MavenDescriptor = "deployMavenDescriptors"
View Source
const Password = "password"
View Source
const Port = "port"
View Source
const PropertiesTempPath = "jfrog/properties/"
View Source
const PropertiesTempPrefix = "buildInfoProperties"

For path and temp files

View Source
const Proxy = "proxy."
View Source
const ReleaseRepo = "releaseRepo"
View Source
const Repo = "repo"
View Source
const ResolverPrefix = "resolver."
View Source
const ServerId = "serverId"
View Source
const SnapshotRepo = "snapshotRepo"
View Source
const Url = "url"
View Source
const Username = "username"

Variables

View Source
var ProjectTypes = []string{
	"go",
	"pip",
	"npm",
	"yarn",
	"nuget",
	"maven",
	"gradle",
	"dotnet",
}
View Source
var RepoTypes = []string{
	"local",
	"remote",
	"virtual",
}

Functions

func AqlResultToSearchResult

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

func CheckIfRepoExists

func CheckIfRepoExists(repository string, artDetails auth.ServiceDetails) 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 CreateBuildInfoPropertiesFile

func CreateBuildInfoPropertiesFile(buildName, buildNumber, projectKey, deployableArtifactsFile string, config *viper.Viper, projectType ProjectType) (string, error)

func CreateBuildInfoService added in v2.5.0

func CreateBuildInfoService() *build.BuildInfoService

func CreateBuildProperties

func CreateBuildProperties(buildName, buildNumber, projectKey string) (string, error)

func CreateDeleteServiceManager

func CreateDeleteServiceManager(artDetails *config.ServerDetails, threads, httpRetries 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 int, dryRun bool, progressBar io.ProgressMgr) (artifactory.ArtifactoryServicesManager, error)

func CreateServiceManager

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

func CreateServiceManagerWithProgressBar

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

func CreateServiceManagerWithThreads

func CreateServiceManagerWithThreads(serverDetails *config.ServerDetails, isDryRun bool, threads, httpRetries 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 int, dryRun bool, progressBar io.ProgressMgr) (artifactory.ArtifactoryServicesManager, error)

func DownloadExtractorIfNeeded

func DownloadExtractorIfNeeded(downloadPath, targetPath string) error

Download the relevant build-info-extractor jar, if it does not already exist locally. By default, the jar is downloaded directly from jfrog releases.

downloadPath: Artifactory download path. filename: The local file name. targetPath: The local download path (without the file name).

func GetBuildDir

func GetBuildDir(buildName, buildNumber, projectKey string) (string, error)

func GetBuildNameAndNumber

func GetBuildNameAndNumber(buildName, buildNumber string) (string, string)

Get build name and number from env, only if both were not provided

func GetBuildProject

func GetBuildProject(buildProject string) string

Get build project from env, if not provided

func GetBuildScanError

func GetBuildScanError() error

func GetEncryptedPasswordFromArtifactory

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

func GetExtractorsRemoteDetails

func GetExtractorsRemoteDetails(downloadPath string) (*config.ServerDetails, string, error)

func GetGeneratedBuildsInfo

func GetGeneratedBuildsInfo(buildName, buildNumber, projectKey string) ([]*buildinfo.BuildInfo, error)

func GetProjectConfFilePath

func GetProjectConfFilePath(projectType ProjectType) (confFilePath string, exists bool, err error)

If configuration file exists in the working dir or in one of its parent dirs return its path, otherwise return the global configuration file path

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 GetRepositories

func GetRepositories(artDetails auth.ServiceDetails, repoType ...RepoType) ([]string, error)

func GetSearchParams

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

func GetServerDetails

func GetServerDetails(vConfig *viper.Viper) (*config.ServerDetails, error)

Returns the Artifactory details Checks first for the deployer information if exists and if not, checks for the resolver information.

func IsRemoteRepo

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

func PrintSearchResults

func PrintSearchResults(reader *content.ContentReader) error

func ReadBuildInfoGeneralDetails

func ReadBuildInfoGeneralDetails(buildName, buildNumber, projectKey string) (*buildinfo.General, error)

func ReadConfigFile

func ReadConfigFile(configPath string, configType ConfigType) (config *viper.Viper, err error)

func ReadPartialBuildInfoFiles

func ReadPartialBuildInfoFiles(buildName, buildNumber, projectKey string) (buildinfo.Partials, error)

func RemoteUnmarshal

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

Download and unmarshal a file from artifactory.

func RemoveBuildDir

func RemoveBuildDir(buildName, buildNumber, projectKey string) error

func SaveBuildGeneralDetails

func SaveBuildGeneralDetails(buildName, buildNumber, projectKey string) error

func SaveBuildInfo

func SaveBuildInfo(buildName, buildNumber, projectKey string, buildInfo *buildinfo.BuildInfo) error

func SavePartialBuildInfo

func SavePartialBuildInfo(buildName, buildNumber, projectKey string, populatePartialBuildInfoFunc populatePartialBuildInfo) error

func SearchResultNoDate

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

func ValidateBuildAndModuleParams

func ValidateBuildAndModuleParams(buildConfig *BuildConfiguration) error

Types

type BuildConfigMapping

type BuildConfigMapping map[ProjectType][]*map[string]string

type BuildConfiguration

type BuildConfiguration struct {
	BuildName   string
	BuildNumber string
	Module      string
	Project     string
}

func ExtractBuildDetailsFromArgs

func ExtractBuildDetailsFromArgs(args []string) (cleanArgs []string, buildConfig *BuildConfiguration, err error)

type ConfigType

type ConfigType string
const (
	YAML       ConfigType = "yaml"
	PROPERTIES ConfigType = "properties"
)

type DownloadConfiguration

type DownloadConfiguration struct {
	Threads         int
	SplitCount      int
	MinSplitSize    int64
	Symlink         bool
	ValidateSymlink bool
}

type ProjectType

type ProjectType int
const (
	Go ProjectType = iota
	Pip
	Npm
	Yarn
	Nuget
	Maven
	Gradle
	Dotnet
)

func (ProjectType) String

func (projectType ProjectType) String() string

type RepoType

type RepoType int
const (
	LOCAL RepoType = iota
	REMOTE
	VIRTUAL
)

func (RepoType) String

func (repoType RepoType) String() string

type Repository

type Repository struct {
	Repo             string `yaml:"repo,omitempty"`
	ServerId         string `yaml:"serverId,omitempty"`
	SnapshotRepo     string `yaml:"snapshotRepo,omitempty"`
	ReleaseRepo      string `yaml:"releaseRepo,omitempty"`
	DeployMavenDesc  bool   `yaml:"deployMavenDescriptors,omitempty"`
	DeployIvyDesc    bool   `yaml:"deployIvyDescriptors,omitempty"`
	IvyPattern       string `yaml:"ivyPattern,omitempty"`
	ArtifactsPattern string `yaml:"artifactPattern,omitempty"`
	NugetV2          bool   `yaml:"nugetV2,omitempty"`
	IncludePatterns  string `yaml:"includePatterns,omitempty"`
	ExcludePatterns  string `yaml:"excludePatterns,omitempty"`
}

type RepositoryConfig

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

func GetRepoConfigByPrefix

func GetRepoConfigByPrefix(configFilePath, prefix string, vConfig *viper.Viper) (*RepositoryConfig, error)

func GetResolutionOnlyConfiguration

func GetResolutionOnlyConfiguration(projectType ProjectType) (*RepositoryConfig, error)

func ReadResolutionOnlyConfiguration

func ReadResolutionOnlyConfiguration(confFilePath string) (*RepositoryConfig, error)

func (*RepositoryConfig) IsServerDetailsEmpty

func (repo *RepositoryConfig) IsServerDetailsEmpty() bool

func (*RepositoryConfig) ServerDetails

func (repo *RepositoryConfig) ServerDetails() (*config.ServerDetails, error)

func (*RepositoryConfig) SetServerDetails

func (repo *RepositoryConfig) SetServerDetails(rtDetails *config.ServerDetails) *RepositoryConfig

func (*RepositoryConfig) SetTargetRepo

func (repo *RepositoryConfig) SetTargetRepo(targetRepo string) *RepositoryConfig

func (*RepositoryConfig) TargetRepo

func (repo *RepositoryConfig) TargetRepo() 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"`
	Md5      string              `json:"md5,omitempty"`
	Props    map[string][]string `json:"props,omitempty"`
}

type UploadConfiguration

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

Directories

Path Synopsis
pip

Jump to

Keyboard shortcuts

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