cliutils

package
v1.39.3 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// General CLI constants
	CliVersion           = "1.39.3"
	ClientAgent          = "jfrog-cli-go"
	OnErrorPanic OnError = "panic"

	// CLI base commands constants:
	CmdArtifactory    = "rt"
	CmdBintray        = "bt"
	CmdMissionControl = "mc"
	CmdXray           = "xr"
	CmdCompletion     = "completion"

	// Download
	DownloadMinSplitKb    = 5120
	DownloadSplitCount    = 3
	DownloadMaxSplitCount = 15

	// Common
	Retries                     = 3
	TokenRefreshDisabled        = 0
	TokenRefreshDefaultInterval = 60
	TokenExpiry                 = 3600
	DefaultLicenseCount         = 1

	// Home Dir
	JfrogCertsDirName        = "certs"
	JfrogConfigFile          = "jfrog-cli.conf"
	JfrogDependenciesDirName = "dependencies"
	JfrogSecurityDirName     = "security"
	JfrogSecurityConfFile    = "security.yaml"
	JfrogBackupDirName       = "backup"
	JfrogLogsDirName         = "logs"
	JfrogLockDirName         = "lock"

	// Env
	ReportUsage     = "JFROG_CLI_REPORT_USAGE"
	LogLevel        = "JFROG_CLI_LOG_LEVEL"
	OfferConfig     = "JFROG_CLI_OFFER_CONFIG"
	HomeDir         = "JFROG_CLI_HOME_DIR"
	ErrorHandling   = "JFROG_CLI_ERROR_HANDLING"
	TempDir         = "JFROG_CLI_TEMP_DIR"
	CI              = "CI"
	DependenciesDir = "JFROG_CLI_DEPENDENCIES_DIR"
	BuildName       = "JFROG_CLI_BUILD_NAME"
	BuildNumber     = "JFROG_CLI_BUILD_NUMBER"
	BuildUrl        = "JFROG_CLI_BUILD_URL"
	EnvExclude      = "JFROG_CLI_ENV_EXCLUDE"
	UserAgent       = "JFROG_CLI_USER_AGENT"
	// Deprecated:
	JfrogHomeEnv = "JFROG_CLI_HOME"
)
View Source
const (
	// Artifactory's Commands Keys
	Config                  = "config"
	Upload                  = "upload"
	Download                = "download"
	Move                    = "move"
	Copy                    = "copy"
	Delete                  = "delete"
	Properties              = "properties"
	Search                  = "search"
	BuildPublish            = "build-publish"
	BuildScan               = "build-scan"
	BuildPromote            = "build-promote"
	BuildDistribute         = "build-distribute"
	BuildDiscard            = "build-discard"
	BuildAddDependencies    = "build-add-dependencies"
	BuildAddGit             = "build-add-git"
	GitLfsClean             = "git-lfs-clean"
	Mvn                     = "mvn"
	MvnConfig               = "mvn-config"
	Gradle                  = "gradle"
	GradleConfig            = "gradle-config"
	DockerPromote           = "docker-promote"
	DockerPull              = "docker-pull"
	DockerPush              = "docker-push"
	NpmConfig               = "npm-config"
	Npm                     = "npm"
	NpmPublish              = "npmPublish"
	NugetConfig             = "nuget-config"
	Nuget                   = "nuget"
	Dotnet                  = "dotnet"
	DotnetConfig            = "dotnet-config"
	Go                      = "go"
	GoConfig                = "go-config"
	GoPublish               = "go-publish"
	GoRecursivePublish      = "go-recursive-publish"
	PipInstall              = "pip-install"
	PipConfig               = "pip-config"
	Ping                    = "ping"
	Curl                    = "curl"
	ReleaseBundleCreate     = "release-bundle-create"
	ReleaseBundleUpdate     = "release-bundle-update"
	ReleaseBundleSign       = "release-bundle-sign"
	ReleaseBundleDistribute = "release-bundle-distribute"
	ReleaseBundleDelete     = "release-bundle-delete"
	TemplateConsumer        = "template-consumer"
	RepoDelete              = "repo-delete"
	ReplicationDelete       = "replication-delete"
	PermissionTargetDelete  = "permission-target-delete"
	AccessTokenCreate       = "access-token-create"
	// MC's Commands Keys
	McConfig       = "mc-config"
	LicenseAcquire = "license-acquire"
	LicenseDeploy  = "license-deploy"
	LicenseRelease = "license-release"
	JpdAdd         = "jpd-add"
	JpdDelete      = "jpd-delete"
	// XRay's Commands Keys
	OfflineUpdate = "offline-update"
)

Variables

View Source
var ExitCodeError = ExitCode{1}
View Source
var ExitCodeFailNoOp = ExitCode{2}
View Source
var ExitCodeNoError = ExitCode{0}
View Source
var ExitCodeVulnerableBuild = ExitCode{3}

Functions

func AskYesNo

func AskYesNo(promptPrefix string, defaultValue bool) bool

Ask a yes or no question, with a default answer.

func CreateDirInJfrogHome

func CreateDirInJfrogHome(dirName string) (string, error)

func CreateSummaryReportString

func CreateSummaryReportString(success, failed int, err error) (string, error)

func ExitOnErr

func ExitOnErr(err error)

func GetBasicBuildToolsFlags added in v1.39.0

func GetBasicBuildToolsFlags() (flags []cli.Flag)

This function is used for mvn and gradle command validation

func GetCliError

func GetCliError(err error, success, failed int, failNoOp bool) error

func GetCliPersistentTempDirPath

func GetCliPersistentTempDirPath() string

Return the path of CLI temp dir. This path should be persistent, meaning - should not be cleared at the end of a CLI run.

func GetCommandFlags added in v1.39.0

func GetCommandFlags(cmd string) []cli.Flag

func GetConfigVersion

func GetConfigVersion() string

func GetDocumentationMessage

func GetDocumentationMessage() string

func GetIntFlagValue

func GetIntFlagValue(c *cli.Context, flagName string, defValue int) (int, error)

func GetInteractiveValue

func GetInteractiveValue(c *cli.Context) bool

This function indicates whether the command should be executed in an interactive mode. If the --interactive option was sent, it is used to determine the mode. If not, the mode will be interactive, unless the CI environment variable was set to true.

func GetJfrogBackupDir

func GetJfrogBackupDir() (string, error)

func GetJfrogCertsDir

func GetJfrogCertsDir() (string, error)

func GetJfrogHomeDir

func GetJfrogHomeDir() (string, error)

func GetJfrogSecurityConfFilePath

func GetJfrogSecurityConfFilePath() (string, error)

func GetJfrogSecurityDir

func GetJfrogSecurityDir() (string, error)

func GetLegacyGoFlags added in v1.39.0

func GetLegacyGoFlags() (flags []cli.Flag)

This function is used for legacy (deprecated) go command validation

func GetLegacyNpmFlags added in v1.39.0

func GetLegacyNpmFlags() (flags []cli.Flag)

This function is used for legacy (deprecated) npm command validation

func GetLegacyNugetFlags added in v1.39.0

func GetLegacyNugetFlags() (flags []cli.Flag)

This function is used for legacy (deprecated) nuget command validation

func GetQuietValue

func GetQuietValue(c *cli.Context) bool

This function indicates whether the command should be executed without confirmation warning or not. If the --quiet option was sent, it is used to determine whether to prompt the confirmation or not. If not, the command will prompt the confirmation, unless the CI environment variable was set to true.

func GetStringsArrFlagValue

func GetStringsArrFlagValue(c *cli.Context, flagName string) (resultArray []string)

func GetUserAgent

func GetUserAgent() string

func GetVersion

func GetVersion() string

func IsLinux

func IsLinux() bool

func IsWindows

func IsWindows() bool

func PanicOnError

func PanicOnError(err error) error

func PrintHelpAndReturnError

func PrintHelpAndReturnError(msg string, context *cli.Context) error

func PrintSummaryReport

func PrintSummaryReport(success, failed int, reader *content.ContentReader, rtUrl string, originalErr error) error

If a resultReader is provided, we will iterate over the result and print a detailed summary including the affected files.

func ReplaceVars

func ReplaceVars(content []byte, specVars map[string]string) []byte

func SpecVarsStringToMap

func SpecVarsStringToMap(rawVars string) map[string]string

func SumTrueValues

func SumTrueValues(boolArr []bool) int

Types

type CliError

type CliError struct {
	ExitCode
	ErrorMsg string
}

func (CliError) Error

func (err CliError) Error() string

type Credentials

type Credentials interface {
	SetUser(string)
	SetPassword(string)
	GetUser() string
	GetPassword() string
}

type ExitCode

type ExitCode struct {
	Code int
}

Exit codes:

func GetExitCode

func GetExitCode(err error, success, failed int, failNoOp bool) ExitCode

type OnError

type OnError string

Error modes (how should the application behave when the CheckError function is invoked):

Jump to

Keyboard shortcuts

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