coreutils

package
v0.0.0-...-6673b58 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// General core constants
	OnErrorPanic OnError = "panic"

	// Common
	TokenRefreshDisabled        = 0
	TokenRefreshDefaultInterval = 60

	// Home Dir
	JfrogBackupDirName                  = "backup"
	JfrogCertsDirName                   = "certs"
	JfrogConfigFile                     = "jfrog-cli.conf"
	JfrogDependenciesDirName            = "dependencies"
	JfrogLocksDirName                   = "locks"
	JfrogLogsDirName                    = "logs"
	JfrogPluginsDirName                 = "plugins"
	JfrogPluginsFileName                = "plugins.yml"
	JfrogSecurityConfFile               = "security.yaml"
	JfrogSecurityDirName                = "security"
	JfrogTransferDelaysDirName          = "delays"
	JfrogTransferDirName                = "transfer"
	JfrogTransferErrorsDirName          = "errors"
	JfrogTransferRepoSnapshotFileName   = "repo-snapshot.json"
	JfrogTransferRepoStateFileName      = "repo-state.json"
	JfrogTransferRepositoriesDirName    = "repositories"
	JfrogTransferTempDirName            = "tmp"
	JfrogTransferRetryableErrorsDirName = "retryable"
	JfrogTransferRunStatusFileName      = "run-status.json"
	JfrogTransferSkippedErrorsDirName   = "skipped"
	JfrogTransferSnapshotDirName        = "snapshot"
	JfrogTransferStateFileName          = "state.json"
	PluginsExecDirName                  = "bin"
	PluginsResourcesDirName             = "resources"
	//#nosec G101
	CurationPassThroughApi = "api/curation/audit/"

	//#nosec G101
	ErrorHandling           = "JFROG_CLI_ERROR_HANDLING"
	TempDir                 = "JFROG_CLI_TEMP_DIR"
	LogLevel                = "JFROG_CLI_LOG_LEVEL"
	LogTimestamp            = "JFROG_CLI_LOG_TIMESTAMP"
	ReportUsage             = "JFROG_CLI_REPORT_USAGE"
	DependenciesDir         = "JFROG_CLI_DEPENDENCIES_DIR"
	FailNoOp                = "JFROG_CLI_FAIL_NO_OP"
	SummaryOutputDirPathEnv = "JFROG_CLI_COMMAND_SUMMARY_OUTPUT_DIR"
	CI                      = "CI"
	ServerID                = "JFROG_CLI_SERVER_ID"
	TransitiveDownload      = "JFROG_CLI_TRANSITIVE_DOWNLOAD"

	// These environment variables are used to adjust command names for more detailed tracking in the usage report.
	// Set by the setup-jfrog-cli GitHub Action to identify specific command usage scenarios.
	// True if an automatic build publication was triggered.
	UsageAutoPublishedBuild = "JFROG_CLI_USAGE_AUTO_BUILD_PUBLISHED"
	// True if the JFrog platform was configured using OIDC integration.
	UsageOidcConfigured = "JFROG_CLI_USAGE_CONFIG_OIDC"

	// Deprecated and replaced with TransitiveDownload
	TransitiveDownloadExperimental = "JFROG_CLI_TRANSITIVE_DOWNLOAD_EXPERIMENTAL"
)
View Source
const (
	GettingStartedGuideUrl = "https://github.com/jfrog/jfrog-cli/blob/v2/guides/getting-started-with-jfrog-using-the-cli.md"
	JFrogComUrl            = "https://jfrog.com/"
	JFrogHelpUrl           = JFrogComUrl + "help/r/"
)
View Source
const (
	// ReleasesRemoteEnv should be used for downloading the CLI dependencies (extractor jars, analyzerManager etc.) 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>'
	ReleasesRemoteEnv = "JFROG_CLI_RELEASES_REPO"
	// DeprecatedExtractorsRemoteEnv is deprecated, it is replaced with ReleasesRemoteEnv.
	// Its functionality was similar to ReleasesRemoteEnv, but it proxies releases.jfrog.io/artifactory/oss-release-local instead.
	DeprecatedExtractorsRemoteEnv = "JFROG_CLI_EXTRACTORS_REMOTE"
	// JFrog releases URL
	JfrogReleasesUrl = "https://releases.jfrog.io/artifactory/"
)

Variables

View Source
var (
	HomeDir     = "JFROG_CLI_HOME_DIR"
	BuildName   = "JFROG_CLI_BUILD_NAME"
	BuildNumber = "JFROG_CLI_BUILD_NUMBER"
	Project     = "JFROG_CLI_BUILD_PROJECT"
	SigningKey  = "JFROG_CLI_SIGNING_KEY"
	KeyAlias    = "JFROG_CLI_KEY_ALIAS"
	//#nosec G101
	EncryptionKey = "JFROG_CLI_ENCRYPTION_KEY"
)

Although these vars are constant, they are defined inside a vars section and not a constants section because the tests modify these values.

View Source
var DefaultMaxColWidth = 25

Controls the max col width when printing to a non-terminal. See the PrintTable description for more info.

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 ChmodPluginsDirectoryContent

func ChmodPluginsDirectoryContent() error

func ConvertExitCodeError

func ConvertExitCodeError(err error) error

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 CreateDirInJfrogHome(dirName string) (string, error)

func ExitOnErr

func ExitOnErr(err error)

func ExtractDetailedSummaryFromArgs

func ExtractDetailedSummaryFromArgs(args []string) (cleanArgs []string, detailedSummary bool, err error)

func ExtractFailFromArgs

func ExtractFailFromArgs(args []string) (cleanArgs []string, fail bool, err error)

Used by docker

func ExtractInsecureTlsFromArgs

func ExtractInsecureTlsFromArgs(args []string) (cleanArgs []string, insecureTls bool, err error)

func ExtractLicensesFromArgs

func ExtractLicensesFromArgs(args []string) (cleanArgs []string, licenses bool, err error)

Used by docker scan (Xray)

func ExtractRepoPathFromArgs

func ExtractRepoPathFromArgs(args []string) (cleanArgs []string, repoPath string, err error)

Used by docker scan (Xray)

func ExtractServerIdFromCommand

func ExtractServerIdFromCommand(args []string) (cleanArgs []string, serverId string, err error)

func ExtractSkipLoginFromArgs

func ExtractSkipLoginFromArgs(args []string) (cleanArgs []string, skipLogin bool, err error)

Used by docker

func ExtractStringOptionFromArgs

func ExtractStringOptionFromArgs(args []string, optionName string) (cleanArgs []string, value string, err error)

func ExtractTagFromArgs

func ExtractTagFromArgs(args []string) (cleanArgs []string, tag string, err error)

func ExtractThreadsFromArgs

func ExtractThreadsFromArgs(args []string, defaultValue int) (cleanArgs []string, threads int, err error)

func ExtractWatchesFromArgs

func ExtractWatchesFromArgs(args []string) (cleanArgs []string, watches string, err error)

Used by docker scan (Xray)

func ExtractXrayOutputFormatFromArgs

func ExtractXrayOutputFormatFromArgs(args []string) (cleanArgs []string, format string, err error)

func ExtractXrayScanFromArgs

func ExtractXrayScanFromArgs(args []string) (cleanArgs []string, xrayScan bool, err error)

func FindBooleanFlag

func FindBooleanFlag(flagName string, args []string) (flagIndex int, flagValue bool, err error)

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 the provided flags in args. Return same values as FindFlag.

func GetCliConfigVersion

func GetCliConfigVersion() int

GetCliConfigVersion returns the latest version of the config.yml file on the file system at '.jfrog'.

func GetCliExecutableName

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 GetFullPathsWorkingDirs

func GetFullPathsWorkingDirs(workingDirs []string) ([]string, error)

Receives a list of relative path working dirs, returns a list of full paths working dirs

func GetJfrogBackupDir

func GetJfrogBackupDir() (string, error)

func GetJfrogCertsDir

func GetJfrogCertsDir() (string, error)

func GetJfrogConfigLockDir

func GetJfrogConfigLockDir() (string, error)

func GetJfrogHomeDir

func GetJfrogHomeDir() (string, error)

func GetJfrogLocksDir

func GetJfrogLocksDir() (string, error)

func GetJfrogPluginsDir

func GetJfrogPluginsDir() (string, error)

func GetJfrogPluginsLockDir

func GetJfrogPluginsLockDir() (string, error)

func GetJfrogPluginsResourcesDir

func GetJfrogPluginsResourcesDir(pluginsName string) (string, error)

func GetJfrogSecurityConfFilePath

func GetJfrogSecurityConfFilePath() (string, error)

func GetJfrogSecurityDir

func GetJfrogSecurityDir() (string, error)

func GetJfrogTransferDir

func GetJfrogTransferDir() (string, error)

func GetJfrogTransferLockDir

func GetJfrogTransferLockDir() (string, error)

func GetJfrogTransferRepositoriesDir

func GetJfrogTransferRepositoriesDir() (string, error)

func GetJfrogTransferRunStatusFilePath

func GetJfrogTransferRunStatusFilePath() (string, error)

func GetJfrogTransferTempDir

func GetJfrogTransferTempDir() (string, error)

func GetJsonIndent

func GetJsonIndent(o any) (strJson string, err error)

func GetMaskedCommandString

func GetMaskedCommandString(cmd *exec.Cmd) string

func GetOSAndArc

func GetOSAndArc() (string, error)

func GetPluginsConfigVersion

func GetPluginsConfigVersion() int

GetPluginsConfigVersion returns the latest plugins layout version on the file system (at '.jfrog/plugins').

func GetPluginsDirContent

func GetPluginsDirContent() ([]os.DirEntry, error)

func GetServerIdAndRepo

func GetServerIdAndRepo(remoteEnv string) (serverID string, repoName string, err error)

func GetWorkingDirectory

func GetWorkingDirectory() (string, error)

func IsAnyEmpty

func IsAnyEmpty(strings ...string) bool

func IsLinux

func IsLinux() bool

func IsMac

func IsMac() bool

func IsWindows

func IsWindows() bool

func ListToText

func ListToText(list []string) string

Turn a list of strings into a sentence. For example, turn ["one", "two", "three"] into "one, two and three". For a single element: "one".

func PanicOnError

func PanicOnError(err error) error

func PrepareTable

func PrepareTable(rows interface{}, emptyTableMessage string, printExtended bool) (table.Writer, error)

Creates table following the logic described in PrintTable. Returns: Table Writer (table.Writer) - Can be used to adjust style, output mirror, render type, etc. Error if occurred.

func PrintBold

func PrintBold(str string) string

Add bold style to the string if possible.

func PrintBoldTitle

func PrintBoldTitle(str string) string

Add bold and green style to the string if possible.

func PrintComment

func PrintComment(str string) string

Add gray color style to the string if possible.

func PrintGreen

func PrintGreen(str string) string

Add green color style to the string if possible.

func PrintLink(str string) string

Add cyan color style to the string if possible.

func PrintMessageInsideFrame

func PrintMessageInsideFrame(message, marginLeft string)

PrintMessage prints message in a frame (which is actually a table with a single table). For example:

┌─────────────────────────────────────────┐ │ An example of a message in a nice frame │ └─────────────────────────────────────────┘ With a margin left of 4 spaces:

    ┌─────────────────────────────────────────┐
	│ An example of a message in a nice frame │
	└─────────────────────────────────────────┘

func PrintRed

func PrintRed(str string) string

Add red color style to the string if possible.

func PrintTable

func PrintTable(rows interface{}, title string, emptyTableMessage string, printExtended bool) (err error)

func PrintTitle

func PrintTitle(str string) string

Add green color style to the string if possible.

func PrintYellow

func PrintYellow(str string) string

Add yellow color style to the string if possible.

func RemoveAllWhiteSpaces

func RemoveAllWhiteSpaces(input string) string

func RemoveEmojisIfNonSupportedTerminal

func RemoveEmojisIfNonSupportedTerminal(msg string) string

Remove emojis from non-supported terminals

func RemoveFlagFromCommand

func RemoveFlagFromCommand(args *[]string, flagIndex, flagValueIndex int)

Removes the provided flag and value from the command arguments

func ReplaceVars

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

func SetCliExecutableName

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 SetIfEmpty(str *string, defaultStr string) bool

func SetPermissionsRecursively

func SetPermissionsRecursively(dirPath string, mode os.FileMode) error

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 GeneralExecCmd

type GeneralExecCmd struct {
	ExecPath string
	Command  []string
}

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 OnError

type OnError string

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

type Profiler

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

This struct wraps the "pprof" profiler in Go. It is used for thread dumping.

func NewProfiler

func NewProfiler(opts ...ProfilerOption) *Profiler

func (*Profiler) ThreadDump

func (p *Profiler) ThreadDump() (output string, err error)

type ProfilerOption

type ProfilerOption func(*Profiler)

func WithInterval

func WithInterval(interval time.Duration) ProfilerOption

func WithRepetitions

func WithRepetitions(repetitions uint) ProfilerOption

Jump to

Keyboard shortcuts

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