Skip to content

Commit

Permalink
update changes to formatoutput
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Dec 18, 2023
1 parent 3384ed8 commit 4444ea7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 58 deletions.
5 changes: 3 additions & 2 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
"github.com/jfrog/jfrog-cli-core/v2/common/build"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
outputFormat "github.com/jfrog/jfrog-cli-core/v2/common/format"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
Expand Down Expand Up @@ -417,7 +418,7 @@ func MvnCmd(c *cli.Context) (err error) {
if !xrayScan && format != "" {
return cliutils.PrintHelpAndReturnError("The --format option can be sent only with the --scan option", c)
}
scanOutputFormat, err := commandsUtils.GetXrayOutputFormat(format)
scanOutputFormat, err := outputFormat.GetOutputFormat(format)
if err != nil {
return err
}
Expand Down Expand Up @@ -469,7 +470,7 @@ func GradleCmd(c *cli.Context) (err error) {
if !xrayScan && format != "" {
return cliutils.PrintHelpAndReturnError("The --format option can be sent only with the --scan option", c)
}
scanOutputFormat, err := commandsUtils.GetXrayOutputFormat(format)
scanOutputFormat, err := outputFormat.GetOutputFormat(format)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ require (
github.com/buger/jsonparser v1.1.1
github.com/go-git/go-git/v5 v5.9.0
github.com/gocarina/gocsv v0.0.0-20230616125104-99d496ca653d
github.com/jfrog/build-info-go v1.9.16
github.com/jfrog/build-info-go v1.9.17
github.com/jfrog/gofrog v1.3.2
github.com/jfrog/jfrog-cli-core/v2 v2.47.3
github.com/jfrog/jfrog-client-go v1.35.0
github.com/jfrog/jfrog-client-go v1.35.1
github.com/jszwec/csvutil v1.8.0
github.com/mholt/archiver/v3 v3.5.1
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -132,7 +132,7 @@ require (

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231130093251-25c79868c10c

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20231214131551-dc1531890f85
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20231218090316-b2d517258419

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.2-0.20231130091721-6d742be8bc7a

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20231214131551-dc1531890f85 h1:hwxs4zOuDbM2w1U4bBAyH+bNtWu59FVtGg6m9FuDQ+c=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20231214131551-dc1531890f85/go.mod h1:RFQwrZ1qXAQ+X0xfuzxBBDIYuRnDsPy12xlyjuOpUog=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20231218090316-b2d517258419 h1:y+tDVgrjqEw3yov6mEhCoNLKy5rITLBO+7OMcSxr59g=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20231218090316-b2d517258419/go.mod h1:6UImGTYUkxOxst/M4wSp6G7dnI24h0OkDW8BnXYhtCE=
github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
Expand Down Expand Up @@ -239,14 +239,14 @@ 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.0 h1:YlI/2zYDrweA4MThiYMKtGRfT+2qZOO65ulej8GTcVI=
github.com/jedib0t/go-pretty/v6 v6.4.0/go.mod h1:MgmISkTWDSFu0xOqiZ0mKNntMQ2mDgOcwOkwBEkMDJI=
github.com/jfrog/build-info-go v1.9.16 h1:zMNxUXve4CZndhlbaEGwgayWPY8CRyPzSobvTKYRPcg=
github.com/jfrog/build-info-go v1.9.16/go.mod h1:/5VZXH2Ud0IK3cOFwPykjwPOaEcHhzzbjnRiou+YKpM=
github.com/jfrog/build-info-go v1.9.17 h1:sUA6V3P8i+awYlK7dkwm4l6IuLE2W964F5Pb18x95HA=
github.com/jfrog/build-info-go v1.9.17/go.mod h1:/5VZXH2Ud0IK3cOFwPykjwPOaEcHhzzbjnRiou+YKpM=
github.com/jfrog/gofrog v1.3.2 h1:TktKP+PdZdxjkYZxWWIq4DkTGSYtr9Slsy+egZpEhUY=
github.com/jfrog/gofrog v1.3.2/go.mod h1:AQo5Fq0G9nDEF6icH7MYQK0iohR4HuEAXl8jaxRuT6Q=
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-client-go v1.35.0 h1:VTyrR/jFlWInRdGYswa2fwFc1Thsh6eGMnHuqhDVh7s=
github.com/jfrog/jfrog-client-go v1.35.0/go.mod h1:cG0vdKXbyfupKgSYmwA5FZPco6zSfyJi3eEYOxuqm/k=
github.com/jfrog/jfrog-client-go v1.35.1 h1:T5HXyRykSCx4cZ//9VCnvHs5rvsPCuNsTU4+CRvkVWk=
github.com/jfrog/jfrog-client-go v1.35.1/go.mod h1:XF/PXHuKILfB1sN3n903yWaWJKJX5VYofDGvO9cJ3+g=
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/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk=
Expand Down
6 changes: 3 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
buildinfo "github.com/jfrog/build-info-go/entities"
commandUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/common/format"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
"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/log"
coreTests "github.com/jfrog/jfrog-cli-core/v2/utils/tests"
xrayutils "github.com/jfrog/jfrog-cli-core/v2/xray/utils"
"github.com/jfrog/jfrog-cli/artifactory"
"github.com/jfrog/jfrog-cli/inttestutils"
"github.com/jfrog/jfrog-cli/utils/tests"
Expand Down Expand Up @@ -279,14 +279,14 @@ func validateCmdAliasesUniqueness() {
func testConditionalUpload(t *testing.T, execFunc func() error, searchSpec string, expectedDeployed ...string) {
// Mock the scan function (failure) and verify the expected error returned.
expectedErrMsg := "This error was expected"
commandUtils.ConditionalUploadScanFunc = func(serverDetails *config.ServerDetails, fileSpec *spec.SpecFiles, threads int, scanOutputFormat xrayutils.OutputFormat) error {
commandUtils.ConditionalUploadScanFunc = func(serverDetails *config.ServerDetails, fileSpec *spec.SpecFiles, threads int, scanOutputFormat format.OutputFormat) error {
return errors.New(expectedErrMsg)
}
err := execFunc()
assert.EqualError(t, err, expectedErrMsg)
inttestutils.VerifyExistInArtifactory(nil, searchSpec, serverDetails, t)
// Mock the scan function (success) and verify the expected artifacts deployed.
commandUtils.ConditionalUploadScanFunc = func(serverDetails *config.ServerDetails, fileSpec *spec.SpecFiles, threads int, scanOutputFormat xrayutils.OutputFormat) error {
commandUtils.ConditionalUploadScanFunc = func(serverDetails *config.ServerDetails, fileSpec *spec.SpecFiles, threads int, scanOutputFormat format.OutputFormat) error {
return nil
}
err = execFunc()
Expand Down
14 changes: 7 additions & 7 deletions scan/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/jfrog/jfrog-cli/utils/progressbar"

commandsutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
outputFormat "github.com/jfrog/jfrog-cli-core/v2/common/format"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
corecommondocs "github.com/jfrog/jfrog-cli-core/v2/docs/common"
coreconfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
Expand Down Expand Up @@ -219,7 +219,7 @@ func CurationCmd(c *cli.Context) error {
if err != nil {
return err
}
format, err := commandsutils.GetCurationOutputFormat(c.String("format"))
format, err := curation.GetCurationOutputFormat(c.String("format"))
if err != nil {
return err
}
Expand All @@ -243,7 +243,7 @@ func createAuditCmd(c *cli.Context) (*audit.AuditCommand, error) {
if err != nil {
return nil, err
}
format, err := commandsutils.GetXrayOutputFormat(c.String("format"))
format, err := outputFormat.GetOutputFormat(c.String("format"))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -308,7 +308,7 @@ func ScanCmd(c *cli.Context) error {
if err != nil {
return err
}
format, err := commandsutils.GetXrayOutputFormat(c.String("format"))
format, err := outputFormat.GetOutputFormat(c.String("format"))
if err != nil {
return err
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func BuildScan(c *cli.Context) error {
if err != nil {
return err
}
format, err := commandsutils.GetXrayOutputFormat(c.String("format"))
format, err := outputFormat.GetOutputFormat(c.String("format"))
if err != nil {
return err
}
Expand All @@ -364,7 +364,7 @@ func BuildScan(c *cli.Context) error {
SetOutputFormat(format).
SetPrintExtendedTable(c.Bool(cliutils.ExtendedTable)).
SetRescan(c.Bool("rescan"))
if format != xrutils.Sarif {
if format != outputFormat.Sarif {
// Sarif shouldn't include the additional all-vulnerabilities info that received by adding the vuln flag
buildScanCmd.SetIncludeVulnerabilities(c.Bool("vuln"))
}
Expand All @@ -387,7 +387,7 @@ func DockerScan(c *cli.Context, image string) error {
return err
}
containerScanCommand := scan.NewDockerScanCommand()
format, err := commandsutils.GetXrayOutputFormat(c.String("format"))
format, err := outputFormat.GetOutputFormat(c.String("format"))
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 4444ea7

Please sign in to comment.