diff --git a/go.mod b/go.mod index 8155088b2..0b3911436 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module github.com/jfrog/jfrog-client-go go 1.20 require ( - github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 github.com/buger/jsonparser v1.1.1 github.com/forPelevin/gomoji v1.1.8 github.com/go-git/go-git/v5 v5.8.1 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/gookit/color v1.5.4 - github.com/jfrog/build-info-go v1.9.8 + github.com/jfrog/build-info-go v1.9.9 github.com/jfrog/gofrog v1.3.0 github.com/mholt/archiver/v3 v3.5.1 github.com/stretchr/testify v1.8.4 @@ -21,7 +21,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect - github.com/CycloneDX/cyclonedx-go v0.7.1 // indirect + github.com/CycloneDX/cyclonedx-go v0.7.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/andybalholm/brotli v1.0.1 // indirect @@ -57,6 +57,6 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230803131422-8230595ceb86 +replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230831090828-915afc4d7380 // replace github.com/jfrog/gofrog => github.com/jfrog/gofrog dev diff --git a/go.sum b/go.sum index 0709ab1aa..8cb1523fe 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/CycloneDX/cyclonedx-go v0.7.1 h1:5w1SxjGm9MTMNTuRbEPyw21ObdbaagTWF/KfF0qHTRE= -github.com/CycloneDX/cyclonedx-go v0.7.1/go.mod h1:N/nrdWQI2SIjaACyyDs/u7+ddCkyl/zkNs8xFsHF2Ps= +github.com/CycloneDX/cyclonedx-go v0.7.2 h1:kKQ0t1dPOlugSIYVOMiMtFqeXI2wp/f5DBIdfux8gnQ= +github.com/CycloneDX/cyclonedx-go v0.7.2/go.mod h1:K2bA+324+Og0X84fA8HhN2X066K7Bxz4rpMQ4ZhjtSk= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= -github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= @@ -51,8 +51,8 @@ github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -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.20230831090828-915afc4d7380 h1:zfcXR/kIDe5npI+k0FdY0pWVTOLbK5kNkf0W0C7r6Gk= +github.com/jfrog/build-info-go v1.8.9-0.20230831090828-915afc4d7380/go.mod h1:QEskae5fQpjeY2PBzsjWtUQVskYSNDF2sSmw/Gx44dQ= 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/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -102,11 +102,15 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/utils/antUtils.go b/utils/antutils.go similarity index 100% rename from utils/antUtils.go rename to utils/antutils.go diff --git a/utils/antUtils_test.go b/utils/antutils_test.go similarity index 100% rename from utils/antUtils_test.go rename to utils/antutils_test.go diff --git a/utils/io/fileutils/files.go b/utils/io/fileutils/files.go index 149ad9b5c..b0a43fc1d 100644 --- a/utils/io/fileutils/files.go +++ b/utils/io/fileutils/files.go @@ -17,7 +17,6 @@ import ( biutils "github.com/jfrog/build-info-go/utils" gofrog "github.com/jfrog/gofrog/io" "github.com/jfrog/jfrog-client-go/utils/errorutils" - "golang.org/x/exp/slices" ) const ( @@ -417,71 +416,6 @@ type FileDetails struct { Size int64 } -func CopyFile(dst, src string) (err error) { - srcFile, err := os.Open(src) - if err != nil { - return errorutils.CheckError(err) - } - defer func() { - err = errors.Join(err, errorutils.CheckError(srcFile.Close())) - }() - fileName, _ := GetFileAndDirFromPath(src) - dstPath, err := CreateFilePath(dst, fileName) - if err != nil { - return err - } - dstFile, err := os.Create(dstPath) - if err != nil { - return errorutils.CheckError(err) - } - defer func() { - err = errors.Join(err, errorutils.CheckError(dstFile.Close())) - }() - _, err = io.Copy(dstFile, srcFile) - return errorutils.CheckError(err) -} - -// Copy directory content from one path to another. -// includeDirs means to copy also the dirs if presented in the src folder. -// excludeNames - Skip files/dirs in the src folder that match names in provided slice. ONLY excludes first layer (only in src folder). -func CopyDir(fromPath, toPath string, includeDirs bool, excludeNames []string) error { - err := CreateDirIfNotExist(toPath) - if err != nil { - return err - } - - files, err := ListFiles(fromPath, includeDirs) - if err != nil { - return err - } - - for _, v := range files { - // Skip if excluded - if slices.Contains(excludeNames, filepath.Base(v)) { - continue - } - - dir, err := IsDirExists(v, false) - if err != nil { - return err - } - - if dir { - toPath := toPath + GetFileSeparator() + filepath.Base(v) - err := CopyDir(v, toPath, true, nil) - if err != nil { - return err - } - continue - } - err = CopyFile(toPath, v) - if err != nil { - return err - } - } - return err -} - // Removing the provided path from the filesystem func RemovePath(testPath string) error { if _, err := os.Stat(testPath); err == nil { @@ -496,7 +430,7 @@ func RemovePath(testPath string) error { // Renaming from old path to new path. func RenamePath(oldPath, newPath string) error { - err := CopyDir(oldPath, newPath, true, nil) + err := biutils.CopyDir(oldPath, newPath, true, nil) if err != nil { return errors.New("Error copying directory: " + oldPath + "to" + newPath + err.Error()) } diff --git a/utils/io/fileutils/files_test.go b/utils/io/fileutils/files_test.go index fff171a5b..cf27e7a51 100644 --- a/utils/io/fileutils/files_test.go +++ b/utils/io/fileutils/files_test.go @@ -1,6 +1,7 @@ package fileutils import ( + biutils "github.com/jfrog/build-info-go/utils" "github.com/jfrog/jfrog-client-go/utils/io" "os" "path/filepath" @@ -262,7 +263,7 @@ func TestRemoveDirContents(t *testing.T) { defer func() { assert.NoError(t, RemoveTempDir(tmpDirPath)) }() - err = CopyDir(filepath.Join("testdata", "removedircontents"), tmpDirPath, true, nil) + err = biutils.CopyDir(filepath.Join("testdata", "removedircontents"), tmpDirPath, true, nil) assert.NoError(t, err) // Run the function diff --git a/utils/tests/utils.go b/utils/tests/utils.go index 3bfef9a3a..515c0a006 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -3,6 +3,7 @@ package tests import ( "bufio" "errors" + biutils "github.com/jfrog/build-info-go/utils" "github.com/jfrog/jfrog-client-go/utils/io/fileutils" "github.com/jfrog/jfrog-client-go/utils/log" "github.com/stretchr/testify/assert" @@ -107,13 +108,13 @@ func exitOnErr(err error) { func InitVcsSubmoduleTestDir(t *testing.T, srcPath, tmpDir string) (submodulePath string) { var err error - assert.NoError(t, fileutils.CopyDir(srcPath, tmpDir, true, nil)) + assert.NoError(t, biutils.CopyDir(srcPath, tmpDir, true, nil)) if found, err := fileutils.IsDirExists(filepath.Join(tmpDir, "gitdata"), false); found { assert.NoError(t, err) assert.NoError(t, fileutils.RenamePath(filepath.Join(tmpDir, "gitdata"), filepath.Join(tmpDir, ".git"))) } submoduleDst := filepath.Join(tmpDir, "subdir", "submodule") - assert.NoError(t, fileutils.CopyFile(submoduleDst, filepath.Join(tmpDir, "gitSubmoduleData"))) + assert.NoError(t, biutils.CopyFile(submoduleDst, filepath.Join(tmpDir, "gitSubmoduleData"))) assert.NoError(t, fileutils.MoveFile(filepath.Join(submoduleDst, "gitSubmoduleData"), filepath.Join(submoduleDst, ".git"))) submodulePath, err = filepath.Abs(submoduleDst) assert.NoError(t, err) @@ -122,7 +123,7 @@ func InitVcsSubmoduleTestDir(t *testing.T, srcPath, tmpDir string) (submodulePat func InitVcsWorktreeTestDir(t *testing.T, srcPath, tmpDir string) (worktreePath string) { var err error - assert.NoError(t, fileutils.CopyDir(srcPath, tmpDir, true, nil)) + assert.NoError(t, biutils.CopyDir(srcPath, tmpDir, true, nil)) if found, err := fileutils.IsDirExists(filepath.Join(tmpDir, "gitdata"), false); found { assert.NoError(t, err) assert.NoError(t, fileutils.RenamePath(filepath.Join(tmpDir, "gitdata"), filepath.Join(tmpDir, "bare.git"))) diff --git a/utils/vcsdetails_test.go b/utils/vcsdetails_test.go index 9720ef35c..d60499681 100644 --- a/utils/vcsdetails_test.go +++ b/utils/vcsdetails_test.go @@ -1,6 +1,7 @@ package utils import ( + biutils "github.com/jfrog/build-info-go/utils" testsutils "github.com/jfrog/jfrog-client-go/utils/tests" "github.com/stretchr/testify/assert" "path/filepath" @@ -42,7 +43,7 @@ func TestVcsDetails(t *testing.T) { func initVcsTestDir(t *testing.T, srcPath, tmpDir string) (projectPath string) { var err error - assert.NoError(t, fileutils.CopyDir(srcPath, tmpDir, true, nil)) + assert.NoError(t, biutils.CopyDir(srcPath, tmpDir, true, nil)) if found, err := fileutils.IsDirExists(filepath.Join(tmpDir, "gitdata"), false); found { assert.NoError(t, err) assert.NoError(t, fileutils.RenamePath(filepath.Join(tmpDir, "gitdata"), filepath.Join(tmpDir, ".git")))