utils

package
v2.56.5 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 36 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NpmConfigAuthKey      = "_auth"
	NpmConfigAuthTokenKey = "_authToken"
)
View Source
const (
	MinJFrogProjectsArtifactoryVersion = "7.0.0"
)

Variables

This section is empty.

Functions

func ConvertTemplateToMap

func ConvertTemplateToMap(tuc TemplateUserCommand) (map[string]interface{}, error)

func CreateArtifactoryClientDetails added in v2.27.0

func CreateArtifactoryClientDetails(serviceManager artifactory.ArtifactoryServicesManager) (*httputils.HttpClientDetails, error)

func CreateCSVFile added in v2.28.0

func CreateCSVFile(filePrefix string, items interface{}, timeStarted time.Time) (csvPath string, err error)

func CreateCollectChecksumsFunc added in v2.10.0

func CreateCollectChecksumsFunc(previousBuildDependencies map[string]*entities.Dependency, servicesManager artifactory.ArtifactoryServicesManager, missingDepsChan chan string) func(dependency *entities.Dependency) (bool, error)

func ExtractDockerOptionsFromArgs added in v2.10.0

func ExtractDockerOptionsFromArgs(args []string) (threads int, serverDetails *config.ServerDetails, detailedSummary, skipLogin bool, cleanArgs []string, buildConfig *build.BuildConfiguration, err error)

Remove all the none docker CLI flags from args.

func ExtractNpmOptionsFromArgs

func ExtractNpmOptionsFromArgs(args []string) (detailedSummary, xrayScan bool, scanOutputFormat outFormat.OutputFormat, cleanArgs []string, buildConfig *build.BuildConfiguration, err error)

Remove all the none npm CLI flags from args.

func ExtractYarnOptionsFromArgs added in v2.10.0

func ExtractYarnOptionsFromArgs(args []string) (threads int, detailedSummary, xrayScan bool, scanOutputFormat format.OutputFormat, cleanArgs []string, buildConfig *build.BuildConfiguration, err error)

func GetArtifactoryNpmRepoDetails

func GetArtifactoryNpmRepoDetails(repo string, authArtDetails auth.ServiceDetails, isNpmAuthLegacyVersion bool) (npmAuth, registry string, err error)

Constructs npm auth config and registry, manually or by requesting the Artifactory /npm/auth endpoint. Since the Artifactory /npm/auth endpoint doesn't handle groups access tokens well, we avoid using it when an access token is configured and the npm version supports setting the token directly. For yarn, this is always supported.

func GetDependenciesFromLatestBuild

func GetDependenciesFromLatestBuild(servicesManager artifactory.ArtifactoryServicesManager, buildName string) (map[string]*entities.Dependency, error)

func GetTransferPluginVersion added in v2.18.1

func GetTransferPluginVersion(client *jfroghttpclient.JfrogHttpClient, url, pluginName string, serverType ServerType, rtDetails *httputils.HttpClientDetails) (string, error)

func InterfaceToMap added in v2.29.8

func InterfaceToMap(jsonInterface interface{}) (map[string]interface{}, error)

Convert the input JSON interface to a map. jsonInterface - JSON interface, such as repository params

func MapToInterface added in v2.41.0

func MapToInterface(mapToTransfer map[string]interface{}) (interface{}, error)

Convert the input map to JSON interface. mapToTransfer - Map of string to interface, such as repository name

func PrintMissingDependencies

func PrintMissingDependencies(missingDependencies []string)

func ScanDeployableArtifacts

func ScanDeployableArtifacts(deployableArtifacts *Result, serverDetails *config.ServerDetails, threads int, format format.OutputFormat) (*spec.SpecFiles, *spec.SpecFiles, error)

ScanDeployableArtifacts scans all files founds in the given parsed deployableArtifacts results. If the scan passes, the function returns two file-specs ready for upload. The first one contains all the binaries and the second all the "pom.xml"s. If one of the file's scan failed both of the return values will be nil.

func ValidateMapEntry

func ValidateMapEntry(key string, value interface{}, writersMap map[string]ioutils.AnswerWriter) error

func ValidateTemplatePath

func ValidateTemplatePath(templatePath string) error

Types

type ConditionalUploadScanFuncType added in v2.9.0

type ConditionalUploadScanFuncType func(serverDetails *config.ServerDetails, fileSpec *spec.SpecFiles, threads int, scanOutputFormat format.OutputFormat) error
var ConditionalUploadScanFunc ConditionalUploadScanFuncType = nil

Function to run as a condition to upload. If not overridden, the default scan function is used.

type Result

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

func UnmarshalDeployableArtifacts

func UnmarshalDeployableArtifacts(deployableArtifactsFilePath, projectConfigPath string, lateDeploy bool) (*Result, error)

UnmarshalDeployableArtifacts reads and parses the deployed artifacts details from the provided file. The details were written by Build-info project while deploying artifacts to maven and gradle repositories. deployableArtifactsFilePath - path to deployableArtifacts file written by Build-info project. projectConfigPath - path to gradle/maven config yaml path. lateDeploy - boolean indicates if the artifacts was expected to be deployed.

func (*Result) FailCount

func (r *Result) FailCount() int

func (*Result) Reader

func (r *Result) Reader() *content.ContentReader

func (*Result) SetFailCount

func (r *Result) SetFailCount(failCount int)

func (*Result) SetReader

func (r *Result) SetReader(reader *content.ContentReader)

func (*Result) SetSuccessCount

func (r *Result) SetSuccessCount(successCount int)

func (*Result) SuccessCount

func (r *Result) SuccessCount() int

type ServerType added in v2.19.1

type ServerType string
const (
	Source                ServerType = "source"
	Target                ServerType = "target"
	PluginsExecuteRestApi            = "api/plugins/execute/"
)

type TemplateUserCommand

type TemplateUserCommand interface {
	// Returns the file path.
	TemplatePath() string
	// Returns vars to replace in the template content.
	Vars() string
}

type TransferConfigBase added in v2.29.8

type TransferConfigBase struct {
	SourceServerDetails      *config.ServerDetails
	TargetServerDetails      *config.ServerDetails
	SourceArtifactoryManager artifactory.ArtifactoryServicesManager
	TargetArtifactoryManager artifactory.ArtifactoryServicesManager
	SourceAccessManager      *access.AccessServicesManager
	TargetAccessManager      *access.AccessServicesManager
	IncludeReposPatterns     []string
	ExcludeReposPatterns     []string
	FederatedMembersRemoved  bool
}

func NewTransferConfigBase added in v2.29.8

func NewTransferConfigBase(sourceServer, targetServer *config.ServerDetails) *TransferConfigBase

func (*TransferConfigBase) CreateServiceManagers added in v2.29.8

func (tcb *TransferConfigBase) CreateServiceManagers(dryRun bool) (err error)

func (*TransferConfigBase) DeactivateKeyEncryption added in v2.29.8

func (tcb *TransferConfigBase) DeactivateKeyEncryption() (reactivateKeyEncryption func() error, err error)

Deactivate key encryption in Artifactory, to allow retrieving raw text values in the artifactory-config.xml or in a remote repository.

func (*TransferConfigBase) GetAllRemoteRepositories added in v2.29.8

func (tcb *TransferConfigBase) GetAllRemoteRepositories(remoteRepositoryNames []string) ([]interface{}, error)

Get all remote repositories. This method must run after disabling Artifactory key encryption. remoteRepositoryNames - Remote repository names to transfer

func (*TransferConfigBase) GetRepoFilter added in v2.29.8

func (tcb *TransferConfigBase) GetRepoFilter() *utils.IncludeExcludeFilter

func (*TransferConfigBase) GetSelectedRepositories added in v2.29.8

func (tcb *TransferConfigBase) GetSelectedRepositories() (map[utils.RepoType][]services.RepositoryDetails, error)

Create a map between the repository types to the list of repositories to transfer.

func (*TransferConfigBase) IsDefaultCredentials added in v2.29.8

func (tcb *TransferConfigBase) IsDefaultCredentials() (bool, error)

Check if there is a configured user using default credentials 'admin:password' by pinging Artifactory.

func (*TransferConfigBase) LogIfFederatedMemberRemoved added in v2.29.8

func (tcb *TransferConfigBase) LogIfFederatedMemberRemoved()

During the transfer-config commands we remove federated members, if existed. This method log an info that the federated members should be reconfigured in the target server.

func (*TransferConfigBase) LogTitle added in v2.29.8

func (tcb *TransferConfigBase) LogTitle(title string)

func (*TransferConfigBase) SetExcludeReposPatterns added in v2.29.8

func (tcb *TransferConfigBase) SetExcludeReposPatterns(excludeReposPatterns []string) *TransferConfigBase

func (*TransferConfigBase) SetIncludeReposPatterns added in v2.29.8

func (tcb *TransferConfigBase) SetIncludeReposPatterns(includeReposPatterns []string) *TransferConfigBase

func (*TransferConfigBase) TransferRepositoriesToTarget added in v2.29.8

func (tcb *TransferConfigBase) TransferRepositoriesToTarget(reposToTransfer map[utils.RepoType][]services.RepositoryDetails, remoteRepositories []interface{}) (err error)

Transfer all repositories to the target Artifactory server reposToTransfer - Map between a repository type to the list of repository names remoteRepositories - Remote repositories params, we get the remote repository params in an earlier stage after decryption

func (*TransferConfigBase) ValidateAccessServerConnection added in v2.41.0

func (tcb *TransferConfigBase) ValidateAccessServerConnection(serverDetails *config.ServerDetails, accessManager *access.AccessServicesManager) error

Make sure that the server is configured with a valid admin Access Token. serverDetails - The server to check accessManager - Access Manager to run ping

func (*TransferConfigBase) ValidateDifferentServers added in v2.34.0

func (tcb *TransferConfigBase) ValidateDifferentServers() error

Make sure source and target Artifactory URLs are different.

type VersionResponse added in v2.18.1

type VersionResponse struct {
	Version string `json:"version,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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