Skip to content

Commit

Permalink
Merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Sep 14, 2023
2 parents f33c559 + 3a430cf commit 54da48c
Show file tree
Hide file tree
Showing 48 changed files with 1,325 additions and 1,256 deletions.
13 changes: 1 addition & 12 deletions artifactory/commands/golang/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import (
"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"
"io/fs"
"net/http"
"os"
"path"
"path/filepath"
"strings"
Expand Down Expand Up @@ -221,16 +219,7 @@ func copyGoPackageFiles(destPath, packageName, rtTargetRepo string, authArtDetai
return fmt.Errorf("couldn't find suitable package files: %s", packageFilesPath)
}
// Set permission recursively
return filepath.WalkDir(destPath, func(path string, info fs.DirEntry, err error) error {
if err != nil {
return err
}
err = os.Chmod(path, 0700)
if err != nil {
return err
}
return nil
})
return coreutils.SetPermissionsRecursively(destPath, 0700)
}

// getPackageFilePathFromArtifactory returns a string that represents the package files cache path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func getDelayUploadComparisonFunctions(packageType string) []shouldDelayUpload {
switch packageType {
case maven, gradle, ivy:
return []shouldDelayUpload{func(fileName string) bool {
return filepath.Ext(fileName) == ".pom"
return filepath.Ext(fileName) == ".pom" || fileName == "pom.xml"
}}
case docker:
return []shouldDelayUpload{func(fileName string) bool {
Expand Down
20 changes: 8 additions & 12 deletions artifactory/commands/transferfiles/state/transfersnapshot.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package state

import (
"github.com/jfrog/jfrog-cli-core/v2/utils/reposnapshot"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"sync"
"time"

"github.com/jfrog/jfrog-cli-core/v2/utils/reposnapshot"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

var saveRepoSnapshotMutex sync.Mutex

type SnapshotActionFunc func(rts *RepoTransferSnapshot) error

var snapshotSaveIntervalMin = snapshotSaveIntervalMinDefault
Expand All @@ -20,8 +23,7 @@ type RepoTransferSnapshot struct {
snapshotManager reposnapshot.RepoSnapshotManager
lastSaveTimestamp time.Time
// This boolean marks that this snapshot continues a previous run. It allows skipping certain checks if it was not loaded, because some data is known to be new.
loadedFromSnapshot bool
saveRepoSnapshotMutex sync.Mutex
loadedFromSnapshot bool
}

// Runs the provided action on the snapshot manager, and periodically saves the repo state and snapshot to the snapshot dir.
Expand All @@ -38,22 +40,16 @@ func (ts *TransferStateManager) snapshotAction(action SnapshotActionFunc) (err e
return nil
}

if !ts.repoTransferSnapshot.saveRepoSnapshotMutex.TryLock() {
if !saveRepoSnapshotMutex.TryLock() {
return nil
}
defer ts.repoTransferSnapshot.saveRepoSnapshotMutex.Unlock()
defer saveRepoSnapshotMutex.Unlock()

ts.repoTransferSnapshot.lastSaveTimestamp = now
if err = ts.repoTransferSnapshot.snapshotManager.PersistRepoSnapshot(); err != nil {
return err
}

return saveStateToSnapshot(&ts.TransferState)
}

func saveStateToSnapshot(ts *TransferState) error {
saveStateMutex.Lock()
defer saveStateMutex.Unlock()
return ts.persistTransferState(true)
}

Expand Down
24 changes: 9 additions & 15 deletions artifactory/utils/dependenciesutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func DownloadAnalyzerManagerIfNeeded() error {
downloadUrl := artDetails.ArtifactoryUrl + remotePath
remoteFileDetails, _, err := client.GetRemoteFileDetails(downloadUrl, &httpClientDetails)
if err != nil {
return err
return fmt.Errorf("couldn't get remote file details for %s: %s", downloadUrl, err.Error())
}
analyzerManagerDir, err := xrayutils.GetAnalyzerManagerDirAbsolutePath()
if err != nil {
Expand All @@ -70,7 +70,8 @@ func DownloadAnalyzerManagerIfNeeded() error {
return err
}
if exist {
sha2, err := fileutils.ReadFile(checksumFilePath)
var sha2 []byte
sha2, err = fileutils.ReadFile(checksumFilePath)
if err != nil {
return err
}
Expand All @@ -84,17 +85,6 @@ func DownloadAnalyzerManagerIfNeeded() error {
if err = DownloadDependency(artDetails, remotePath, filepath.Join(analyzerManagerDir, xrayutils.AnalyzerManagerZipName), true); err != nil {
return err
}
// Add permission for all unzipped files
filesList, err := fileutils.ListFilesRecursiveWalkIntoDirSymlink(analyzerManagerDir, false)
if err != nil {
return err
}
for _, file := range filesList {
if err = os.Chmod(file, 0777); err != nil {
return errorutils.CheckError(err)
}
}

return createChecksumFile(checksumFilePath, remoteFileDetails.Checksum.Sha256)
}

Expand Down Expand Up @@ -219,9 +209,13 @@ func DownloadDependency(artDetails *config.ServerDetails, downloadPath, targetPa
return err
}
resp, err := client.DownloadFile(downloadFileDetails, "", &httpClientDetails, shouldExplode, false)
if err == nil && resp.StatusCode != http.StatusOK {
err = errorutils.CheckErrorf(resp.Status + " received when attempting to download " + downloadUrl)
if err != nil {
err = errorutils.CheckErrorf("received error while attempting to download '%s': %s"+downloadUrl, err.Error())
}
if err = errorutils.CheckResponseStatus(resp, http.StatusOK); err != nil {
return err
}
err = coreutils.SetPermissionsRecursively(tempDirPath, 0700)
if err != nil {
return err
}
Expand Down
30 changes: 12 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ require (
github.com/google/uuid v1.3.1
github.com/gookit/color v1.5.4
github.com/jedib0t/go-pretty/v6 v6.4.7
github.com/jfrog/build-info-go v1.9.9
github.com/jfrog/build-info-go v1.9.10
github.com/jfrog/gofrog v1.3.0
github.com/jfrog/jfrog-client-go v1.31.6
github.com/jfrog/jfrog-client-go v1.32.2
github.com/magiconair/properties v1.8.7
github.com/manifoldco/promptui v0.9.0
github.com/owenrumney/go-sarif/v2 v2.2.0
Expand All @@ -23,13 +23,12 @@ require (
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.14
github.com/vbauerster/mpb/v7 v7.5.3
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/mod v0.12.0
golang.org/x/sync v0.3.0
golang.org/x/term v0.11.0
golang.org/x/text v0.12.0
golang.org/x/term v0.12.0
golang.org/x/text v0.13.0
gopkg.in/yaml.v3 v3.0.1

)

require (
Expand All @@ -44,13 +43,14 @@ require (
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.4.1 // indirect
github.com/go-git/go-git/v5 v5.8.1 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.9.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.2 // indirect
Expand Down Expand Up @@ -86,16 +86,10 @@ require (
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/tools v0.13.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230831152946-6ed2ae1aa57f

replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230905120411-62d1bdd4eb38

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27
Loading

0 comments on commit 54da48c

Please sign in to comment.