Documentation ¶
Index ¶
- Constants
- Variables
- func AskYesNo(promptPrefix string, defaultValue bool) bool
- func ConvertExitCodeError(err error) error
- func CreateDirInJfrogHome(dirName string) (string, error)
- func DetectTechnologies(path string, limitTechnologiesSupport, recursive bool) (map[Technology]bool, error)
- func ExitOnErr(err error)
- func ExtractDetailedSummaryFromArgs(args []string) (cleanArgs []string, detailedSummary bool, err error)
- func ExtractInsecureTlsFromArgs(args []string) (cleanArgs []string, insecureTls bool, err error)
- func ExtractXrayOutputFormatFromArgs(args []string) (cleanArgs []string, format string, err error)
- func ExtractXrayScanFromArgs(args []string) (cleanArgs []string, xrayScan bool, err error)
- func FindBooleanFlag(flagName string, args []string) (flagIndex int, flagValue bool, err error)
- func FindFlag(flagName string, args []string) (flagIndex, flagValueIndex int, flagValue string, err error)
- func FindFlagFirstMatch(flags, args []string) (flagIndex, flagValueIndex int, flagValue string, err error)
- func GetCliExecutableName() string
- func GetCliPersistentTempDirPath() string
- func GetCliUserAgent() string
- func GetCliUserAgentName() string
- func GetCliUserAgentVersion() string
- func GetClientAgentName() string
- func GetClientAgentVersion() string
- func GetConfigVersion() int
- func GetJfrogBackupDir() (string, error)
- func GetJfrogCertsDir() (string, error)
- func GetJfrogConfigLockDir() (string, error)
- func GetJfrogHomeDir() (string, error)
- func GetJfrogLocksDir() (string, error)
- func GetJfrogPluginsDir() (string, error)
- func GetJfrogSecurityConfFilePath() (string, error)
- func GetJfrogSecurityDir() (string, error)
- func GetWorkingDirectory() (string, error)
- func IsAnyEmpty(strings ...string) bool
- func IsLinux() bool
- func IsTerminal() bool
- func IsWindows() bool
- func PanicOnError(err error) error
- func ParseArgs(args []string) ([]string, error)
- func PrintBold(str string) string
- func PrintComment(str string) string
- func PrintLink(str string) string
- func PrintMessage(message string)
- func PrintTable(rows interface{}, title string, emptyTableMessage string) error
- func PrintTitle(str string) string
- func RemoveFlagFromCommand(args *[]string, flagIndex, flagValueIndex int)
- func ReplaceVars(content []byte, specVars map[string]string) []byte
- func SetCliExecutableName(executableName string)
- func SetCliUserAgentName(cliUserAgentNameToSet string)
- func SetCliUserAgentVersion(versionToSet string)
- func SetClientAgentName(clientAgentToSet string)
- func SetClientAgentVersion(versionToSet string)
- func SetIfEmpty(str *string, defaultStr string) bool
- func SpecVarsStringToMap(rawVars string) map[string]string
- func StringsSliceContains(slice []string, str string) bool
- func SumTrueValues(boolArr []bool) int
- type CliError
- type Credentials
- type ExitCode
- type GeneralExecCmd
- type GoIndicator
- type GradleIndicator
- type MavenIndicator
- type NpmIndicator
- type OnError
- type PypiIndicator
- type Technology
- type TechnologyIndicator
Constants ¶
const ( // General core constants OnErrorPanic OnError = "panic" // Common TokenRefreshDisabled = 0 TokenRefreshDefaultInterval = 60 // Home Dir JfrogCertsDirName = "certs" JfrogConfigFile = "jfrog-cli.conf" JfrogDependenciesDirName = "dependencies" JfrogSecurityDirName = "security" JfrogSecurityConfFile = "security.yaml" JfrogBackupDirName = "backup" JfrogLogsDirName = "logs" JfrogLocksDirName = "locks" JfrogPluginsDirName = "plugins" // Env ErrorHandling = "JFROG_CLI_ERROR_HANDLING" TempDir = "JFROG_CLI_TEMP_DIR" LogLevel = "JFROG_CLI_LOG_LEVEL" ReportUsage = "JFROG_CLI_REPORT_USAGE" DependenciesDir = "JFROG_CLI_DEPENDENCIES_DIR" TransitiveDownload = "JFROG_CLI_TRANSITIVE_DOWNLOAD_EXPERIMENTAL" CI = "CI" )
const ( Maven = "Maven" Gradle = "Gradle" Npm = "npm" Go = "go" Pypi = "pypi" )
const GettingStartedGuideUrl = "https://github.com/jfrog/jfrog-cli/blob/v2/guides/getting-started-with-jfrog-using-the-cli.md"
Variables ¶
var ( HomeDir = "JFROG_CLI_HOME_DIR" BuildName = "JFROG_CLI_BUILD_NAME" BuildNumber = "JFROG_CLI_BUILD_NUMBER" Project = "JFROG_CLI_BUILD_PROJECT" )
Although these vars are constant, they are defined inside a vars section and not a constants section because the tests modify these values.
var ExitCodeError = ExitCode{1}
var ExitCodeFailNoOp = ExitCode{2}
var ExitCodeNoError = ExitCode{0}
var ExitCodeVulnerableBuild = ExitCode{3}
Functions ¶
func ConvertExitCodeError ¶ added in v2.1.0
When running a command in an external process, if the command fails to run or doesn't complete successfully ExitError is returned. We would like to return a regular error instead of ExitError, because some frameworks (such as codegangsta used by JFrog CLI) automatically exit when this error is returned.
func CreateDirInJfrogHome ¶
func DetectTechnologies ¶ added in v2.7.0
func DetectTechnologies(path string, limitTechnologiesSupport, recursive bool) (map[Technology]bool, error)
func ExtractXrayOutputFormatFromArgs ¶ added in v2.4.1
func ExtractXrayScanFromArgs ¶
func FindBooleanFlag ¶
Boolean flag can be provided in one of the following forms: 1. --flag=value, where value can be true/false 2. --flag, here the value is true Return values: flagIndex - index of flagName in args. flagValue - value of flagName. err - error if flag exists, but we failed to extract its value. If flag does not exist flagIndex = -1 with false value and nil error.
func FindFlag ¶
func FindFlag(flagName string, args []string) (flagIndex, flagValueIndex int, flagValue string, err error)
Find value of required CLI flag in Command. If flag does not exist, the returned index is -1 and nil is returned as the error. Return values: err - error if flag exists but failed to extract its value. flagIndex - index of flagName in Command. flagValueIndex - index in Command in which the value of the flag exists. flagValue - value of flagName.
func FindFlagFirstMatch ¶
func FindFlagFirstMatch(flags, args []string) (flagIndex, flagValueIndex int, flagValue string, err error)
Find the first match of any of the provided flags in args. Return same values as FindFlag.
func GetCliExecutableName ¶ added in v2.5.0
func GetCliExecutableName() string
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 GetCliUserAgent ¶
func GetCliUserAgent() string
func GetCliUserAgentName ¶
func GetCliUserAgentName() string
func GetCliUserAgentVersion ¶
func GetCliUserAgentVersion() string
func GetClientAgentName ¶
func GetClientAgentName() string
func GetClientAgentVersion ¶
func GetClientAgentVersion() string
func GetConfigVersion ¶
func GetConfigVersion() int
func GetJfrogBackupDir ¶
func GetJfrogCertsDir ¶
func GetJfrogConfigLockDir ¶ added in v2.2.0
func GetJfrogHomeDir ¶
func GetJfrogLocksDir ¶ added in v2.2.0
func GetJfrogPluginsDir ¶
func GetJfrogSecurityDir ¶
func GetWorkingDirectory ¶
func IsAnyEmpty ¶
func IsTerminal ¶ added in v2.1.0
func IsTerminal() bool
IsTerminal checks whether stdout is a terminal.
func PanicOnError ¶
func ParseArgs ¶
Iterate over each argument, if env variable is found (e.g $HOME) replace it with env value.
func PrintComment ¶ added in v2.7.2
Print the test to the console in gray color.
func PrintMessage ¶ added in v2.1.0
func PrintMessage(message string)
PrintMessage prints message in a frame (which is actaully a table with a single table). For example: ┌─────────────────────────────────────────┐ │ An example of a message in a nice frame │ └─────────────────────────────────────────┘
func PrintTable ¶ added in v2.1.0
PrintTable prints a slice of rows in a table. The parameter rows MUST be a slice, otherwise the method panics. How to use this method (with an example): The fields of the struct must have one of the tags: 'col-name' or 'embed-table' in order to be printed. Fields without any of these tags will be skipped. The tag 'col-name' can be set on string fields only. The column name is the 'col-name' tag value. If the cell content exceeds the defined col-max-width, the content will be broken into two (or more) lines. If you would like to limit the width of the column, you can use the 'col-max-width' tag. In case the struct you want to print contains a field that is a slice of other structs, you can print it in the table too with the 'embed-table' tag which can be set on slices of structs only.
Example: These are the structs Customer and Product:
type Customer struct { name string `col-name:"Name"` age string `col-name:"Age"` products []Product `embed-table:"true"` }
type Product struct { title string `col-name:"Product Title" col-max-width:"15"` CatNumber string `col-name:"Product\nCatalog #"` }
We'll use it, and run these commands:
customersSlice := []Customer{ {name: "Gai", age: "350", products: []Product{{title: "SpiderFrog Shirt - Medium", CatNumber: "123456"}, {title: "Floral Bottle", CatNumber: "147585"}}}, {name: "Noah", age: "21", products: []Product{{title: "Pouch", CatNumber: "456789"}, {title: "Ching Ching", CatNumber: "963852"}}}, }
err := coreutils.PrintTable(customersSlice, "Customers", "No customers were found")
That's the table printed:
Customers ┌──────┬─────┬─────────────────┬───────────┐ │ NAME │ AGE │ PRODUCT TITLE │ PRODUCT │ │ │ │ │ CATALOG # │ ├──────┼─────┼─────────────────┼───────────┤ │ Gai │ 350 │ SpiderFrog Shir │ 123456 │ │ │ │ t - Medium │ │ │ │ │ Floral Bottle │ 147585 │ ├──────┼─────┼─────────────────┼───────────┤ │ Noah │ 21 │ Pouch │ 456789 │ │ │ │ Ching Ching │ 963852 │ └──────┴─────┴─────────────────┴───────────┘
If customersSlice was empty, emptyTableMessage would have been printed instead:
Customers ┌─────────────────────────┐ │ No customers were found │ └─────────────────────────┘
func PrintTitle ¶ added in v2.7.2
Print the test to the console in green color.
func RemoveFlagFromCommand ¶
Removes the provided flag and value from the command arguments
func SetCliExecutableName ¶ added in v2.5.0
func SetCliExecutableName(executableName string)
func SetCliUserAgentName ¶
func SetCliUserAgentName(cliUserAgentNameToSet string)
func SetCliUserAgentVersion ¶
func SetCliUserAgentVersion(versionToSet string)
func SetClientAgentName ¶
func SetClientAgentName(clientAgentToSet string)
func SetClientAgentVersion ¶
func SetClientAgentVersion(versionToSet string)
func SetIfEmpty ¶
func SpecVarsStringToMap ¶
func StringsSliceContains ¶
func SumTrueValues ¶
Types ¶
type Credentials ¶
type GeneralExecCmd ¶
Command used to execute general commands.
func (*GeneralExecCmd) GetCmd ¶
func (pluginCmd *GeneralExecCmd) GetCmd() *exec.Cmd
func (*GeneralExecCmd) GetEnv ¶
func (pluginCmd *GeneralExecCmd) GetEnv() map[string]string
func (*GeneralExecCmd) GetErrWriter ¶
func (pluginCmd *GeneralExecCmd) GetErrWriter() io.WriteCloser
func (*GeneralExecCmd) GetStdWriter ¶
func (pluginCmd *GeneralExecCmd) GetStdWriter() io.WriteCloser
type GoIndicator ¶ added in v2.7.0
type GoIndicator struct { }
func (GoIndicator) GetTechnology ¶ added in v2.7.0
func (gi GoIndicator) GetTechnology() Technology
func (GoIndicator) Indicates ¶ added in v2.7.0
func (gi GoIndicator) Indicates(file string) bool
type GradleIndicator ¶ added in v2.7.0
type GradleIndicator struct { }
func (GradleIndicator) GetTechnology ¶ added in v2.7.0
func (gi GradleIndicator) GetTechnology() Technology
func (GradleIndicator) Indicates ¶ added in v2.7.0
func (gi GradleIndicator) Indicates(file string) bool
type MavenIndicator ¶ added in v2.7.0
type MavenIndicator struct { }
func (MavenIndicator) GetTechnology ¶ added in v2.7.0
func (mi MavenIndicator) GetTechnology() Technology
func (MavenIndicator) Indicates ¶ added in v2.7.0
func (mi MavenIndicator) Indicates(file string) bool
type NpmIndicator ¶ added in v2.7.0
type NpmIndicator struct { }
func (NpmIndicator) GetTechnology ¶ added in v2.7.0
func (ni NpmIndicator) GetTechnology() Technology
func (NpmIndicator) Indicates ¶ added in v2.7.0
func (ni NpmIndicator) Indicates(file string) bool
type OnError ¶
type OnError string
Error modes (how should the application behave when the CheckError function is invoked):
type PypiIndicator ¶ added in v2.7.0
type PypiIndicator struct { }
func (PypiIndicator) GetTechnology ¶ added in v2.7.0
func (pi PypiIndicator) GetTechnology() Technology
func (PypiIndicator) Indicates ¶ added in v2.7.0
func (pi PypiIndicator) Indicates(file string) bool
type Technology ¶ added in v2.7.0
type Technology string
type TechnologyIndicator ¶ added in v2.7.0
type TechnologyIndicator interface { GetTechnology() Technology Indicates(file string) bool }
func GetMinSupportedTechIndicators ¶ added in v2.7.0
func GetMinSupportedTechIndicators() []TechnologyIndicator
func GetTechIndicators ¶ added in v2.7.0
func GetTechIndicators() []TechnologyIndicator