Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible race condition when running commands #216

Merged
merged 2 commits into from
Nov 30, 2023
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: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ require (
golang.org/x/sys v0.12.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.2-0.20231130091721-6d742be8bc7a
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jfrog/gofrog v1.3.1 h1:QqAwQXCVReT724uga1AYqG/ZyrNQ6f+iTxmzkb+YFQk=
github.com/jfrog/gofrog v1.3.1/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
github.com/jfrog/gofrog v1.3.2-0.20231130091721-6d742be8bc7a h1:SCgU7ho+YAu+8lo2U5Tr0gH8PQV6mVGaoywXH8He4Ng=
github.com/jfrog/gofrog v1.3.2-0.20231130091721-6d742be8bc7a/go.mod h1:AQo5Fq0G9nDEF6icH7MYQK0iohR4HuEAXl8jaxRuT6Q=
github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU=
github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
Expand Down
65 changes: 0 additions & 65 deletions utils/command.go

This file was deleted.

9 changes: 5 additions & 4 deletions utils/goutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"regexp"
"runtime"

"github.com/jfrog/gofrog/io"
"github.com/jfrog/gofrog/version"

"os"
Expand Down Expand Up @@ -39,7 +40,7 @@ func RunGo(goArg []string, repoUrl string) error {
return err
}

goCmd := NewCommand("go", "", goArg)
goCmd := io.NewCommand("go", "", goArg)
err = prepareGlobalRegExp()
if err != nil {
return err
Expand Down Expand Up @@ -148,7 +149,7 @@ func runDependenciesCmd(projectDir string, commandArgs []string, log Log) (outpu
}
}()
}
goCmd := NewCommand("go", "", commandArgs)
goCmd := io.NewCommand("go", "", commandArgs)
goCmd.Dir = projectDir

err = prepareGlobalRegExp()
Expand Down Expand Up @@ -230,7 +231,7 @@ func GetParsedGoVersion() (*version.Version, error) {
}

func getGoVersion() (string, error) {
goCmd := NewCommand("go", "version", nil)
goCmd := io.NewCommand("go", "version", nil)
output, err := gofrogcmd.RunCmdOutput(goCmd)
return output, err
}
Expand Down Expand Up @@ -288,7 +289,7 @@ func GetGoModCachePath() (string, error) {

// GetGOPATH returns the location of the GOPATH
func getGOPATH() (string, error) {
goCmd := NewCommand("go", "env", []string{"GOPATH"})
goCmd := io.NewCommand("go", "env", []string{"GOPATH"})
output, err := gofrogcmd.RunCmdOutput(goCmd)
if err != nil {
return "", fmt.Errorf("could not find GOPATH env: %s", err.Error())
Expand Down
5 changes: 3 additions & 2 deletions utils/pythonutils/pipenvutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package pythonutils

import (
"encoding/json"
"github.com/jfrog/build-info-go/utils"

"github.com/jfrog/gofrog/io"
)

// Executes pipenv graph.
Expand All @@ -11,7 +12,7 @@ import (
// 'topLevelPackagesList' - list of all top level dependencies ( root dependencies only)
func getPipenvDependencies(srcPath string) (dependenciesGraph map[string][]string, topLevelDependencies []string, err error) {
// Run pipenv graph
pipenvGraphCmd := utils.NewCommand("pipenv", "graph", []string{"--json"})
pipenvGraphCmd := io.NewCommand("pipenv", "graph", []string{"--json"})
pipenvGraphCmd.Dir = srcPath
output, err := pipenvGraphCmd.RunWithOutput()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion utils/pythonutils/piputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/jfrog/build-info-go/utils"
"github.com/jfrog/gofrog/io"
)

// Executes the pip-dependency-map script and returns a dependency map of all the installed pip packages in the current environment to and another list of the top level dependencies
Expand All @@ -18,7 +19,7 @@ func getPipDependencies(srcPath, dependenciesDirName string) (map[string][]strin
if err != nil {
return nil, nil, err
}
localPipdeptree := utils.NewCommand("python", "", []string{localPipdeptreeScript, "--json"})
localPipdeptree := io.NewCommand("python", "", []string{localPipdeptreeScript, "--json"})
localPipdeptree.Dir = srcPath
output, err := localPipdeptree.RunWithOutput()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion utils/pythonutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/jfrog/build-info-go/entities"
"github.com/jfrog/build-info-go/utils"
"github.com/jfrog/gofrog/io"
gofrogcmd "github.com/jfrog/gofrog/io"
)

Expand Down Expand Up @@ -210,7 +211,7 @@ func InstallWithLogParsing(tool PythonTool, commandArgs []string, log utils.Log,
// Add verbosity flag to pipenv commands to collect necessary data
commandArgs = append(commandArgs, "-v")
}
installCmd := utils.NewCommand(string(tool), "install", commandArgs)
installCmd := io.NewCommand(string(tool), "install", commandArgs)
installCmd.Dir = srcPath

dependenciesMap := map[string]entities.Dependency{}
Expand Down
Loading