Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Aug 28, 2023
2 parents ab61366 + e44caa0 commit b41d4f0
Show file tree
Hide file tree
Showing 22 changed files with 514 additions and 105 deletions.
4 changes: 2 additions & 2 deletions artifactory/commands/container/containermanagerbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

Expand Down Expand Up @@ -59,7 +59,7 @@ func (ccb *ContainerCommandBase) IsGetRepoSupported() (bool, error) {
if err != nil {
return false, err
}
err = coreutils.ValidateMinimumVersion(coreutils.Artifactory, currentVersion, MinRtVersionForRepoFetching)
err = clientutils.ValidateMinimumVersion(clientutils.Artifactory, currentVersion, MinRtVersionForRepoFetching)
return err == nil, nil
}

Expand Down
4 changes: 2 additions & 2 deletions artifactory/commands/golang/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
goutils "github.com/jfrog/jfrog-cli-core/v2/utils/golang"
rtutils "github.com/jfrog/jfrog-client-go/artifactory/services/utils"
"github.com/jfrog/jfrog-client-go/auth"
"github.com/jfrog/jfrog-client-go/http/httpclient"
rtutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
Expand Down Expand Up @@ -261,7 +261,7 @@ func getPackageFilePathFromArtifactory(packageName, rtTargetRepo string, authArt
// PackageName string should be in the following format: <Package Path>/@V/<Requested Branch Name>.info OR latest.info
// For example the jfrog/jfrog-cli/@v/master.info packageName will return the corresponding canonical version (vX.Y.Z) string for the jfrog-cli master branch.
func getPackageVersion(repoName, packageName string, details auth.ServiceDetails) (string, error) {
artifactoryApiUrl, err := rtutils.BuildArtifactoryUrl(details.GetUrl(), "api/go/"+repoName, make(map[string]string))
artifactoryApiUrl, err := rtutils.BuildUrl(details.GetUrl(), "api/go/"+repoName, make(map[string]string))
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions artifactory/commands/golang/gopublish.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package golang

import (
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"os/exec"

"github.com/jfrog/build-info-go/build"
commandutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
goutils "github.com/jfrog/jfrog-cli-core/v2/utils/golang"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

Expand Down Expand Up @@ -82,7 +82,7 @@ func (gpc *GoPublishCommand) Run() error {
if err != nil {
return err
}
err = coreutils.ValidateMinimumVersion(coreutils.Artifactory, artifactoryVersion, minSupportedArtifactoryVersion)
err = clientutils.ValidateMinimumVersion(clientutils.Artifactory, artifactoryVersion, minSupportedArtifactoryVersion)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions artifactory/commands/transferconfig/transferconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func (tcc *TransferConfigCommand) validateMinVersion() (sourceArtifactoryVersion
}

// Validate minimal Artifactory version in the source server
err = coreutils.ValidateMinimumVersion(coreutils.Artifactory, sourceArtifactoryVersion, minTransferConfigArtifactoryVersion)
err = clientutils.ValidateMinimumVersion(clientutils.Artifactory, sourceArtifactoryVersion, minTransferConfigArtifactoryVersion)
if err != nil {
return
}
Expand All @@ -565,7 +565,7 @@ func (tcc *TransferConfigCommand) validateServerPrerequisites() (err error) {
}

// Check connectivity to JFrog Access if the source Artifactory version is >= 7.0.0
if versionErr := coreutils.ValidateMinimumVersion(coreutils.Projects, sourceArtifactoryVersion, commandsUtils.MinJFrogProjectsArtifactoryVersion); versionErr == nil {
if versionErr := clientutils.ValidateMinimumVersion(clientutils.Projects, sourceArtifactoryVersion, commandsUtils.MinJFrogProjectsArtifactoryVersion); versionErr == nil {
if err = tcc.ValidateAccessServerConnection(tcc.SourceServerDetails, tcc.SourceAccessManager); err != nil {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
commandsUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
"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"
accessServices "github.com/jfrog/jfrog-client-go/access/services"
"github.com/jfrog/jfrog-client-go/artifactory/services"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
"golang.org/x/exp/slices"
)
Expand Down Expand Up @@ -99,7 +99,7 @@ func (tcmc *TransferConfigMergeCommand) initServiceManagersAndValidateServers()
return
}
// Check if JFrog Projects supported by Source Artifactory version
versionErr := coreutils.ValidateMinimumVersion(coreutils.Projects, sourceArtifactoryVersion, commandsUtils.MinJFrogProjectsArtifactoryVersion)
versionErr := clientutils.ValidateMinimumVersion(clientutils.Projects, sourceArtifactoryVersion, commandsUtils.MinJFrogProjectsArtifactoryVersion)
if versionErr != nil {
// Projects not supported by Source Artifactory version
return
Expand Down
6 changes: 4 additions & 2 deletions artifactory/commands/transferfiles/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
"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"
usageReporter "github.com/jfrog/jfrog-cli-core/v2/utils/usage"
serviceUtils "github.com/jfrog/jfrog-client-go/artifactory/services/utils"
"github.com/jfrog/jfrog-client-go/artifactory/usage"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
Expand Down Expand Up @@ -234,7 +236,7 @@ func (tdc *TransferFilesCommand) initStateManager(allSourceLocalRepos, sourceBui
}

func (tdc *TransferFilesCommand) reportTransferFilesUsage() {
log.Debug(usage.ReportUsagePrefix + "Sending Transfer Files info...")
log.Debug(usageReporter.ReportUsagePrefix, "Sending Transfer Files info...")
sourceStorageInfo, err := tdc.sourceStorageInfoManager.GetStorageInfo()
if err != nil {
log.Debug(err.Error())
Expand Down Expand Up @@ -708,7 +710,7 @@ func validateDataTransferPluginMinimumVersion(currentVersion string) error {
if strings.Contains(currentVersion, "SNAPSHOT") {
return nil
}
return coreutils.ValidateMinimumVersion(coreutils.DataTransfer, currentVersion, dataTransferPluginMinVersion)
return clientutils.ValidateMinimumVersion(clientutils.DataTransfer, currentVersion, dataTransferPluginMinVersion)
}

// Verify connection to the source Artifactory instance, and that the user plugin is installed, responsive, and stands in the minimal version requirement.
Expand Down
7 changes: 4 additions & 3 deletions artifactory/commands/transferfiles/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/utils/tests"
"github.com/jfrog/jfrog-client-go/artifactory"
"github.com/jfrog/jfrog-client-go/artifactory/services"
clientUtils "github.com/jfrog/jfrog-client-go/artifactory/services/utils"
artifactoryUtils "github.com/jfrog/jfrog-client-go/artifactory/services/utils"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -117,7 +118,7 @@ func testValidateDataTransferPluginMinimumVersion(t *testing.T, curVersion strin
pluginVersion = curVersion
err := getAndValidateDataTransferPlugin(srcPluginManager)
if errorExpected {
assert.EqualError(t, err, coreutils.ValidateMinimumVersion(coreutils.DataTransfer, curVersion, dataTransferPluginMinVersion).Error())
assert.EqualError(t, err, clientutils.ValidateMinimumVersion(clientutils.DataTransfer, curVersion, dataTransferPluginMinVersion).Error())
return
}
assert.NoError(t, err)
Expand Down Expand Up @@ -319,7 +320,7 @@ func TestGetAllLocalRepositories(t *testing.T) {
case "/api/storageinfo":
// Response for GetStorageInfo
w.WriteHeader(http.StatusOK)
response := &clientUtils.StorageInfo{RepositoriesSummaryList: []clientUtils.RepositorySummary{
response := &artifactoryUtils.StorageInfo{RepositoriesSummaryList: []artifactoryUtils.RepositorySummary{
{RepoKey: "repo-1"}, {RepoKey: "repo-2"},
{RepoKey: "federated-repo-1"}, {RepoKey: "federated-repo-2"},
{RepoKey: "artifactory-build-info", PackageType: "BuildInfo"}, {RepoKey: "proj-build-info", PackageType: "BuildInfo"}},
Expand Down
3 changes: 2 additions & 1 deletion artifactory/commands/utils/npmcmdutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/auth"
"github.com/jfrog/jfrog-client-go/http/httpclient"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
)
Expand Down Expand Up @@ -54,7 +55,7 @@ func validateArtifactoryVersionForNpmCmds(artDetails *auth.ServiceDetails) error
}

// Validate version.
return coreutils.ValidateMinimumVersion(coreutils.Artifactory, versionStr, minSupportedArtifactoryVersionForNpmCmds)
return clientutils.ValidateMinimumVersion(clientutils.Artifactory, versionStr, minSupportedArtifactoryVersionForNpmCmds)
}

func getNpmAuthFromArtifactory(artDetails *auth.ServiceDetails) (npmAuth string, err error) {
Expand Down
3 changes: 2 additions & 1 deletion artifactory/utils/container/containermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/auth"
"github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
)
Expand Down Expand Up @@ -257,5 +258,5 @@ func ValidateClientApiVersion() error {
log.Error("The Docker client Api version is expected to be 'major.minor'. The actual output is:", content)
return errorutils.CheckError(err)
}
return coreutils.ValidateMinimumVersion(coreutils.DockerApi, content, MinSupportedApiVersion)
return utils.ValidateMinimumVersion(utils.DockerApi, content, MinSupportedApiVersion)
}
41 changes: 0 additions & 41 deletions artifactory/utils/gradleinitscript.go

This file was deleted.

14 changes: 5 additions & 9 deletions common/commands/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"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"
usageReporter "github.com/jfrog/jfrog-cli-core/v2/utils/usage"
"github.com/jfrog/jfrog-client-go/artifactory/usage"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
)

Expand All @@ -31,22 +31,18 @@ func Exec(command Command) error {

func reportUsage(command Command, channel chan<- bool) {
defer signalReportUsageFinished(channel)
reportUsage, err := clientutils.GetBoolEnvValue(coreutils.ReportUsage, true)
if err != nil {
log.Debug(usage.ReportUsagePrefix + err.Error())
return
}
reportUsage := usageReporter.ShouldReportUsage()
if reportUsage {
serverDetails, err := command.ServerDetails()
if err != nil {
log.Debug(usage.ReportUsagePrefix + err.Error())
log.Debug(usageReporter.ReportUsagePrefix, err.Error())
return
}
if serverDetails != nil && serverDetails.ArtifactoryUrl != "" {
log.Debug(usage.ReportUsagePrefix + "Sending info...")
log.Debug(usageReporter.ReportUsagePrefix, "Sending info...")
serviceManager, err := utils.CreateServiceManager(serverDetails, -1, 0, false)
if err != nil {
log.Debug(usage.ReportUsagePrefix + err.Error())
log.Debug(usageReporter.ReportUsagePrefix, err.Error())
return
}
err = usage.SendReportUsage(coreutils.GetCliUserAgent(), command.CommandName(), serviceManager)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/jedib0t/go-pretty/v6 v6.4.6
github.com/jfrog/build-info-go v1.9.8
github.com/jfrog/gofrog v1.3.0
github.com/jfrog/jfrog-client-go v1.31.5
github.com/jfrog/jfrog-client-go v1.31.6
github.com/magiconair/properties v1.8.7
github.com/manifoldco/promptui v0.9.0
github.com/owenrumney/go-sarif/v2 v2.2.0
Expand Down Expand Up @@ -95,6 +95,6 @@ require (

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230803140217-0a5f43783ae8

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230820165857-52ff32c4d8eb
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230828134416-f0db33dd9344

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw=
github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs=
github.com/jfrog/build-info-go v1.9.8 h1:D8/ga+YgQpqp/CJj2zteS4/twmSy8zvm1v9lCd2Kv1M=
github.com/jfrog/build-info-go v1.9.8/go.mod h1:t31QRpH5xUJKw8XkQlAA+Aq7aanyS1rrzpcK8xSNVts=
github.com/jfrog/build-info-go v1.8.9-0.20230828134416-f0db33dd9344 h1:zU+F+61OSnafhH3lq9b3dEKgrM5KodrCRXXRc2/wcZ0=
github.com/jfrog/build-info-go v1.8.9-0.20230828134416-f0db33dd9344/go.mod h1:t31QRpH5xUJKw8XkQlAA+Aq7aanyS1rrzpcK8xSNVts=
github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk=
github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
github.com/jfrog/jfrog-client-go v1.31.5 h1:dYVgIJzMwX+EU9GEELKPSHFLyfW6UrrjZWMEZtAyx6A=
github.com/jfrog/jfrog-client-go v1.31.5/go.mod h1:icb00ZJN/mMMNkQduHDkzpqsXH9Flwi3f3COYexq3Nc=
github.com/jfrog/jfrog-client-go v1.31.6 h1:uWuyT4BDm9s5ES6oDTBny9Gl6yf8iKFjcbmHSHQZrDc=
github.com/jfrog/jfrog-client-go v1.31.6/go.mod h1:icb00ZJN/mMMNkQduHDkzpqsXH9Flwi3f3COYexq3Nc=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
21 changes: 1 addition & 20 deletions utils/coreutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"runtime"
"strings"

"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
Expand All @@ -24,16 +23,6 @@ const (
JFrogHelpUrl = JFrogComUrl + "help/r/"
)

type MinVersionProduct string

const (
Artifactory MinVersionProduct = "JFrog Artifactory"
Xray MinVersionProduct = "JFrog Xray"
DataTransfer MinVersionProduct = "Data Transfer"
DockerApi MinVersionProduct = "Docker API"
Projects MinVersionProduct = "JFrog Projects"
)

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
Expand All @@ -44,8 +33,7 @@ const (
// 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/"
MinimumVersionMsg = "You are using %s version %s, while this operation requires version %s or higher."
JfrogReleasesUrl = "https://releases.jfrog.io/artifactory/"
)

// Error modes (how should the application behave when the CheckError function is invoked):
Expand Down Expand Up @@ -561,13 +549,6 @@ func GetJfrogTransferDir() (string, error) {
return filepath.Join(homeDir, JfrogTransferDirName), nil
}

func ValidateMinimumVersion(product MinVersionProduct, currentVersion, minimumVersion string) error {
if !version.NewVersion(currentVersion).AtLeast(minimumVersion) {
return errorutils.CheckErrorf(MinimumVersionMsg, product, currentVersion, minimumVersion)
}
return nil
}

func GetServerIdAndRepo(remoteEnv string) (serverID string, repoName string, err error) {
serverAndRepo := os.Getenv(remoteEnv)
if serverAndRepo == "" {
Expand Down
3 changes: 1 addition & 2 deletions utils/gradle/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"path/filepath"
"strings"

"github.com/jfrog/build-info-go/build"
"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 @@ -53,7 +52,7 @@ func getGradleDependencyLocalPath() (string, error) {
if err != nil {
return "", err
}
return filepath.Join(dependenciesPath, "gradle", build.GradleExtractorDependencyVersion), nil
return filepath.Join(dependenciesPath, "gradle"), nil
}

func createGradleRunConfig(vConfig *viper.Viper, deployableArtifactsFile string, threads int, disableDeploy bool) (props map[string]string, wrapper, plugin bool, err error) {
Expand Down
Loading

0 comments on commit b41d4f0

Please sign in to comment.