Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion artifactory/commands/transfer/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (tst *TransferSettingsCommand) Run() error {
ioutils.ScanFromConsole("Set the maximum number of working threads", &threadsNumberInput, currThreadsNumber)
threadsNumber, err := strconv.Atoi(threadsNumberInput)
if err != nil || threadsNumber < 1 || threadsNumber > MaxThreadsLimit {
return errorutils.CheckErrorf("the value must be a number between 1 and " + strconv.Itoa(MaxThreadsLimit))
return errorutils.CheckErrorf("the value must be a number between 1 and %s", strconv.Itoa(MaxThreadsLimit))
}
conf := &utils.TransferSettings{ThreadsNumber: threadsNumber}
err = utils.SaveTransferSettings(conf)
Expand Down
2 changes: 1 addition & 1 deletion artifactory/commands/transferconfig/transferconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (tcc *TransferConfigCommand) verifyConfigImportPlugin() error {

// Unexpected status received: 403 if the user is not admin, 500+ if there is a server error
messageFormat := fmt.Sprintf("Target server response: %s.\n%s", resp.Status, body)
return errorutils.CheckErrorf(messageFormat)
return errors.New(messageFormat)
}

// Creates the Pre-checks runner for the config import command
Expand Down
2 changes: 1 addition & 1 deletion artifactory/commands/transferfiles/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func uploadChunkWhenPossibleHandler(pcWrapper *producerConsumerWrapper, phaseBas
shouldStop := uploadChunkWhenPossible(pcWrapper, phaseBase, chunk, uploadTokensChan, errorsChannelMng)
if shouldStop {
// The specific error that triggered the stop is already in the errors channel
return errorutils.CheckErrorf(logMsgPrefix + "stopped")
return errorutils.CheckErrorf("%sstopped", logMsgPrefix)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions artifactory/commands/utils/templateutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func ConvertTemplateToMaps(templateUserCommand TemplateUserCommand) (interface{}

func ValidateMapEntry(key string, value interface{}, writersMap map[string]ioutils.AnswerWriter) error {
if _, ok := writersMap[key]; !ok {
return errorutils.CheckErrorf("template syntax error: unknown key: \"" + key + "\".")
return errorutils.CheckErrorf("template syntax error: unknown key: \"%s\".", key)
}
if _, ok := value.(string); !ok {
return errorutils.CheckErrorf("template syntax error: the value for the key: \"" + key + "\" is not a string type.")
return errorutils.CheckErrorf("template syntax error: the value for the key: \"%s\" is not a string type.", key)
}
return nil
}
Expand Down
8 changes: 5 additions & 3 deletions artifactory/commands/utils/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package utils

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"time"

"github.com/gocarina/gocsv"
ioutils "github.com/jfrog/gofrog/io"
logutils "github.com/jfrog/jfrog-cli-core/v2/utils/log"
"github.com/jfrog/jfrog-client-go/http/jfroghttpclient"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/io/httputils"
"net/http"
"time"
)

type ServerType string
Expand Down Expand Up @@ -40,7 +42,7 @@ func GetTransferPluginVersion(client *jfroghttpclient.JfrogHttpClient, url, plug
return "", errorutils.CheckErrorf("%sIt looks like the %s plugin is not installed on the %s server.", messageFormat, pluginName, serverType)
} else {
// 403 if the user is not admin, 500+ if there is a server error
return "", errorutils.CheckErrorf(messageFormat)
return "", errors.New(messageFormat)
}
}

Expand Down
8 changes: 4 additions & 4 deletions artifactory/utils/container/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func newBuildInfoBuilder(image *Image, repository, buildName, buildNumber, proje
repoDetails := &services.RepositoryDetails{}
err = serviceManager.GetRepository(repository, &repoDetails)
if err != nil {
return nil, errorutils.CheckErrorf("failed to get details for repository '" + repository + "'. Error:\n" + err.Error())
return nil, errorutils.CheckErrorf("failed to get details for repository '%s'. Error:\n%s", repository, err.Error())
}

builder.repositoryDetails.isRemote = repoDetails.GetRepoType() == "remote"
Expand Down Expand Up @@ -324,11 +324,11 @@ func GetImageTagWithDigest(filePath string) (*Image, string, error) {
// Try read Kaniko/oc file.
splittedData := strings.Split(string(data), `@`)
if len(splittedData) != 2 {
return nil, "", errorutils.CheckErrorf(`unexpected file format "` + filePath + `". The file should include one line in the following format: image-tag@sha256`)
return nil, "", errorutils.CheckErrorf(`unexpected file format "%s". The file should include one line in the following format: image-tag@sha256`, filePath)
}
tag, sha256 := splittedData[0], strings.Trim(splittedData[1], "\n")
if tag == "" || sha256 == "" {
err = errorutils.CheckErrorf(`missing image-tag/sha256 in file: "` + filePath + `"`)
err = errorutils.CheckErrorf(`missing image-tag/sha256 in file: "%s"`, filePath)
if err != nil {
return nil, "", err
}
Expand Down Expand Up @@ -609,7 +609,7 @@ func getDependenciesFromManifestConfig(candidateLayers map[string]*utils.ResultI
dependencies = append(dependencies, getManifestDependency(manifestSearchResults))
imageDetails, found := candidateLayers[digestToLayer(imageSha2)]
if !found {
return nil, errorutils.CheckErrorf("failed to collect build-info. Image '" + imageSha2 + "' was not found in Artifactory")
return nil, errorutils.CheckErrorf("failed to collect build-info. Image '%s' was not found in Artifactory", imageSha2)
}

return append(dependencies, imageDetails.ToDependency()), nil
Expand Down
2 changes: 1 addition & 1 deletion artifactory/utils/container/containermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (containerManager *containerManager) OsCompatibility(image *Image) (string,
content = strings.Trim(content, "\n")
firstSeparator := strings.Index(content, ",")
if firstSeparator == -1 {
return "", "", errorutils.CheckErrorf("couldn't find OS and architecture of image:" + image.name)
return "", "", errorutils.CheckErrorf("couldn't find OS and architecture of image: %s", image.name)
}
return content[:firstSeparator], content[firstSeparator+1:], err
}
Expand Down
7 changes: 4 additions & 3 deletions artifactory/utils/container/image.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package container

import (
"errors"
"net/http"
"path"
"strconv"
Expand Down Expand Up @@ -154,15 +155,15 @@ func (image *Image) GetRemoteRepo(serviceManager artifactory.ArtifactoryServices
return "", err
}
if resp.StatusCode == http.StatusForbidden {
return "", errorutils.CheckErrorf(getStatusForbiddenErrorMessage())
return "", errors.New(getStatusForbiddenErrorMessage())
}
if resp.StatusCode != http.StatusOK {
return "", errorutils.CheckErrorf("error while getting docker repository name. Artifactory response: " + resp.Status)
return "", errorutils.CheckErrorf("error while getting docker repository name. Artifactory response: %s", resp.Status)
}
if dockerRepo := resp.Header["X-Artifactory-Docker-Registry"]; len(dockerRepo) != 0 {
return dockerRepo[0], nil
}
return "", errorutils.CheckErrorf("couldn't find 'X-Artifactory-Docker-Registry' header docker repository in artifactory")
return "", errors.New("couldn't find 'X-Artifactory-Docker-Registry' header docker repository in artifactory")
}

// Returns the name of the repository containing the image in Artifactory.
Expand Down
2 changes: 1 addition & 1 deletion artifactory/utils/container/localagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,5 @@ func handleForeignLayer(layerMediaType, layerFileName string) error {
log.Info(fmt.Sprintf("Foreign layer: %s is missing in Artifactory and therefore will not be added to the build-info.", layerFileName))
return nil
}
return errorutils.CheckErrorf("Could not find layer: " + layerFileName + " in Artifactory")
return errorutils.CheckErrorf("Could not find layer: %s in Artifactory", layerFileName)
}
4 changes: 2 additions & 2 deletions artifactory/utils/container/remoteagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (rabib *RemoteAgentBuildInfoBuilder) handleManifest(resultMap map[string]*u
log.Debug("Found manifest.json. Proceeding to create build-info.")
return resultMap, manifest, nil
}
return nil, nil, errorutils.CheckErrorf(`couldn't find image "` + rabib.buildInfoBuilder.image.name + `" manifest in Artifactory`)
return nil, nil, errorutils.CheckErrorf(`couldn't find image "%s" manifest in Artifactory`, rabib.buildInfoBuilder.image.name)
}

func (rabib *RemoteAgentBuildInfoBuilder) handleFatManifestImage(results map[string]*utils.ResultItem) (map[string][]*utils.ResultItem, *utils.ResultItem, *FatManifest, error) {
Expand All @@ -79,7 +79,7 @@ func (rabib *RemoteAgentBuildInfoBuilder) handleFatManifestImage(results map[str
multiPlatformImages, err := performMultiPlatformImageSearch(fatManifestRootPath, rabib.buildInfoBuilder.serviceManager)
return multiPlatformImages, fatManifestResult, fatManifest, err
}
return nil, nil, nil, errorutils.CheckErrorf(`couldn't find image "` + rabib.buildInfoBuilder.image.name + `" fat manifest in Artifactory`)
return nil, nil, nil, errorutils.CheckErrorf(`couldn't find image "%s" fat manifest in Artifactory`, rabib.buildInfoBuilder.image.name)
}

// Search image manifest or fat-manifest of and image.
Expand Down
9 changes: 5 additions & 4 deletions artifactory/utils/repositoryutils.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package utils

import (
"os"
"path"
"strings"

"github.com/jfrog/gofrog/datastructures"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"golang.org/x/exp/slices"
"os"
"path"
"strings"

"github.com/jfrog/jfrog-client-go/artifactory"
"github.com/jfrog/jfrog-client-go/artifactory/services"
Expand Down Expand Up @@ -77,7 +78,7 @@ func IsRemoteRepo(repoName string, serviceManager artifactory.ArtifactoryService
repoDetails := &services.RepositoryDetails{}
err := serviceManager.GetRepository(repoName, &repoDetails)
if err != nil {
return false, errorutils.CheckErrorf("failed to get details for repository '" + repoName + "'. Error:\n" + err.Error())
return false, errorutils.CheckErrorf("failed to get details for repository '%s'. Error:\n%s", repoName, err.Error())
}
return repoDetails.GetRepoType() == "remote", nil
}
Expand Down
6 changes: 3 additions & 3 deletions artifactory/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func GetEncryptedPasswordFromArtifactory(artifactoryAuth auth.ServiceDetails, in
if resp.StatusCode == http.StatusConflict {
message := "\nYour Artifactory server is not configured to encrypt passwords.\n" +
"You may use \"art config --enc-password=false\""
return "", errorutils.CheckErrorf(message)
return "", errors.New(message)
}

return "", errorutils.CheckErrorf("Artifactory response: " + resp.Status + "\n" + clientUtils.IndentJson(body))
return "", errorutils.CheckErrorf("Artifactory response: %s\n%s", resp.Status, clientUtils.IndentJson(body))
}

func CreateServiceManager(serverDetails *config.ServerDetails, httpRetries, httpRetryWaitMilliSecs int, isDryRun bool) (artifactory.ArtifactoryServicesManager, error) {
Expand Down Expand Up @@ -342,7 +342,7 @@ func ValidateRepoExists(repoKey string, serviceDetails auth.ServiceDetails) erro
}

if !exists {
return errorutils.CheckErrorf("The repository '" + repoKey + "' does not exist.")
return errorutils.CheckErrorf("The repository '%s' does not exist.", repoKey)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions artifactory/utils/yarn/versionVerify.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package yarn

import (
"strings"

gofrogcmd "github.com/jfrog/gofrog/io"
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"strings"
)

const unsupportedYarnVersion = "4.0.0"
Expand All @@ -22,8 +23,7 @@ func IsInstalledYarnVersionSupported(executablePath string) error {
func IsVersionSupported(versionStr string) error {
yarnVersion := version.NewVersion(versionStr)
if yarnVersion.Compare(unsupportedYarnVersion) <= 0 {
return errorutils.CheckErrorf("Yarn version 4 is not supported. The current version is: " + versionStr +
". Please downgrade to a compatible version to continue")
return errorutils.CheckErrorf("Yarn version 4 is not supported. The current version is: %s. Please downgrade to a compatible version to continue", versionStr)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions common/build/buildinfoproperties.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func GetServerDetails(vConfig *viper.Viper) (*config.ServerDetails, error) {

func CreateBuildInfoProps(buildArtifactsDetailsFile string, config *viper.Viper, projectType project.ProjectType) (map[string]string, error) {
if config.GetString("type") != projectType.String() {
return nil, errorutils.CheckErrorf("Incompatible build config, expected: " + projectType.String() + " got: " + config.GetString("type"))
return nil, errorutils.CheckErrorf("Incompatible build config, expected: %s, got: %s", projectType.String(), config.GetString("type"))
}
if err := setServerDetailsToConfig(ResolverPrefix, config); err != nil {
return nil, err
Expand Down Expand Up @@ -300,7 +300,7 @@ func setServerDetailsToConfig(contextPrefix string, vConfig *viper.Viper) error
return err
}
if artDetails.GetArtifactoryUrl() == "" {
return errorutils.CheckErrorf("Server ID " + serverId + ": URL is required.")
return errorutils.CheckErrorf("Server ID %s URL is required.", serverId)
}
vConfig.Set(contextPrefix+Url, artDetails.GetArtifactoryUrl())

Expand Down
5 changes: 3 additions & 2 deletions common/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package commands
import (
"errors"
"fmt"
generic "github.com/jfrog/jfrog-cli-core/v2/general/token"
"net/url"
"os"
"reflect"
"strconv"
"strings"
"sync"

generic "github.com/jfrog/jfrog-cli-core/v2/general/token"

"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
Expand Down Expand Up @@ -134,7 +135,7 @@ func (cc *ConfigCommand) Run() (err error) {
case Clear:
err = cc.clear()
default:
err = fmt.Errorf("Not supported config command type: " + string(cc.cmdType))
err = fmt.Errorf("Not supported config command type: %s", string(cc.cmdType))
}
return
}
Expand Down
9 changes: 5 additions & 4 deletions common/commands/configfile.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package commands

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -580,7 +581,7 @@ func validateRepositoryConfig(repository *project.Repository, errorPrefix string
snapshotRepo := repository.SnapshotRepo

if repository.ServerId != "" && repository.Repo == "" && releaseRepo == "" && snapshotRepo == "" {
return errorutils.CheckErrorf(errorPrefix + setRepositoryError)
return errors.New(errorPrefix + setRepositoryError)
}
// Server-id flag was not provided.
if repository.ServerId == "" {
Expand All @@ -601,7 +602,7 @@ func validateRepositoryConfig(repository *project.Repository, errorPrefix string
if serverId == "" {
// Repositories flags were provided.
if repository.Repo != "" || releaseRepo != "" || snapshotRepo != "" {
return errorutils.CheckErrorf(errorPrefix + setServerIdError)
return errors.New(errorPrefix + setServerIdError)
}
} else if repository.Repo != "" || releaseRepo != "" || snapshotRepo != "" {
// Server-id flag wasn't provided and repositories flags were provided - the default configured global server will be chosen.
Expand All @@ -610,7 +611,7 @@ func validateRepositoryConfig(repository *project.Repository, errorPrefix string
}
// Release/snapshot repositories should be entangled to each other.
if (releaseRepo == "" && snapshotRepo != "") || (releaseRepo != "" && snapshotRepo == "") {
return errorutils.CheckErrorf(errorPrefix + setSnapshotAndReleaseError)
return errors.New(errorPrefix + setSnapshotAndReleaseError)
}
return nil
}
Expand All @@ -632,7 +633,7 @@ func readArtifactoryServer(useArtifactoryQuestion string) (string, error) {
return "", err
}
if len(serversIds) == 0 {
return "", errorutils.CheckErrorf("No Artifactory servers configured. Use the 'jfrog c add' command to set the Artifactory server details.")
return "", errors.New("No Artifactory servers configured. Use the 'jfrog c add' command to set the Artifactory server details.")
}

// Ask whether to use artifactory
Expand Down
2 changes: 1 addition & 1 deletion common/format/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetOutputFormat(formatFlagVal string) (format OutputFormat, err error) {
case string(CycloneDx):
format = CycloneDx
default:
err = errorutils.CheckErrorf("only the following output formats are supported: " + coreutils.ListToText(OutputFormats))
err = errorutils.CheckErrorf("only the following output formats are supported: %s", coreutils.ListToText(OutputFormats))
}
}
return
Expand Down
2 changes: 1 addition & 1 deletion common/project/projectconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func GetResolutionOnlyConfiguration(projectType ProjectType) (*RepositoryConfig,
return nil, err
}
if !exists {
return nil, errorutils.CheckErrorf(projectType.String() + " Project configuration does not exist.")
return nil, errorutils.CheckErrorf("%s Project configuration does not exist.", projectType.String())
}
return ReadResolutionOnlyConfiguration(confFilePath)
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/jfrog/jfrog-cli-core/v2

go 1.23.7
go 1.24.4

require github.com/c-bata/go-prompt v0.2.5 // Should not be updated to 0.2.6 due to a bug (https://github.com/jfrog/jfrog-cli-core/pull/372)

Expand All @@ -13,9 +13,9 @@ require (
github.com/google/uuid v1.6.0
github.com/gookit/color v1.5.4
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/jfrog/build-info-go v1.10.14
github.com/jfrog/build-info-go v1.10.15
github.com/jfrog/gofrog v1.7.6
github.com/jfrog/jfrog-client-go v1.54.3
github.com/jfrog/jfrog-client-go v1.54.4
github.com/magiconair/properties v1.8.9
github.com/manifoldco/promptui v0.9.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3N
github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs=
github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI=
github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw=
github.com/jfrog/build-info-go v1.10.14 h1:PWnw+rBwiQTHZ5q+84+E8MHFjtAQkB3+Oc2sKwBSSGE=
github.com/jfrog/build-info-go v1.10.14/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
github.com/jfrog/build-info-go v1.10.15 h1:y6E87iIBTofNy4mus6Ngv6AtVwg/bN/Rz+oaI3kpN4M=
github.com/jfrog/build-info-go v1.10.15/go.mod h1:+8u1CEGrr8XY5a5U6farFW3EKYk0ge0BMGZE3BAZBcE=
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
github.com/jfrog/jfrog-client-go v1.54.3 h1:tIhhDhM7rDMT1lzgeQy4nr6H2ihlqnumhiFybIWlLz0=
github.com/jfrog/jfrog-client-go v1.54.3/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
github.com/jfrog/jfrog-client-go v1.54.4 h1:W5J2WAidEPghlvWl7FbrJUeRyVbNzC6GnihNACVaeEM=
github.com/jfrog/jfrog-client-go v1.54.4/go.mod h1:+pSVE7Co+ytwhOhmz84/Lpe5fSeTaWJXsP1qt+WVfw0=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
2 changes: 1 addition & 1 deletion missioncontrol/commands/jpdadd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func JpdAdd(flags *JpdAddFlags) error {
return err
}
if resp.StatusCode != http.StatusCreated {
return errorutils.CheckErrorf(resp.Status + ". " + utils.ReadMissionControlHttpMessage(body))
return errorutils.CheckErrorf("%s. %s", resp.Status, utils.ReadMissionControlHttpMessage(body))
}

log.Debug("Mission Control response: " + resp.Status)
Expand Down
Loading
Loading