Skip to content

Commit

Permalink
Command Summaries (#2552)
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea authored May 23, 2024
1 parent 560584b commit 2d277d9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ func uploadCmd(c *cli.Context) (err error) {
if err != nil {
return
}
printDeploymentView, detailedSummary := log.IsStdErrTerminal(), c.Bool("detailed-summary")
printDeploymentView, detailedSummary := log.IsStdErrTerminal(), cliutils.GetDetailedSummary(c)
uploadCmd.SetUploadConfiguration(configuration).SetBuildConfiguration(buildConfiguration).SetSpec(uploadSpec).SetServerDetails(rtDetails).SetDryRun(c.Bool("dry-run")).SetSyncDeletesPath(c.String("sync-deletes")).SetQuiet(cliutils.GetQuietValue(c)).SetDetailedSummary(detailedSummary || printDeploymentView).SetRetries(retries).SetRetryWaitMilliSecs(retryWaitTime)

if uploadCmd.ShouldPrompt() && !coreutils.AskYesNo("Sync-deletes may delete some artifacts in Artifactory. Are you sure you want to continue?\n"+
Expand Down Expand Up @@ -1666,7 +1666,7 @@ func buildPublishCmd(c *cli.Context) error {
if err != nil {
return err
}
buildPublishCmd := buildinfo.NewBuildPublishCommand().SetServerDetails(rtDetails).SetBuildConfiguration(buildConfiguration).SetConfig(buildInfoConfiguration).SetDetailedSummary(c.Bool("detailed-summary"))
buildPublishCmd := buildinfo.NewBuildPublishCommand().SetServerDetails(rtDetails).SetBuildConfiguration(buildConfiguration).SetConfig(buildInfoConfiguration).SetDetailedSummary(cliutils.GetDetailedSummary(c))

err = commands.Exec(buildPublishCmd)
if buildPublishCmd.IsDetailedSummary() {
Expand Down
8 changes: 7 additions & 1 deletion docs/common/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const (
JfrogCliAvoidNewVersionWarning = ` JFROG_CLI_AVOID_NEW_VERSION_WARNING
[Default: false]
Set to true if you'd like to avoid checking the latest available JFrog CLI version and printing warning when it newer than the current one. `

JfrogCliCommandSummaryOutputDirectory = ` JFROG_CLI_COMMAND_SUMMARY_OUTPUT_DIR
Defines the directory path where the command summaries data is stored.
Every command will have its own individual directory within this base directory.
. `
)

var (
Expand Down Expand Up @@ -129,7 +134,8 @@ func GetGlobalEnvVars() string {
JfrogCliEnvExclude,
JfrogCliFailNoOp,
JfrogCliEncryptionKey,
JfrogCliAvoidNewVersionWarning)
JfrogCliAvoidNewVersionWarning,
JfrogCliCommandSummaryOutputDirectory)
}

func CreateEnvVars(envVars ...string) string {
Expand Down
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ require (
github.com/go-git/go-git/v5 v5.12.0
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/jfrog/archiver/v3 v3.6.0
github.com/jfrog/build-info-go v1.9.26
github.com/jfrog/build-info-go v1.9.27
github.com/jfrog/gofrog v1.7.1
github.com/jfrog/jfrog-cli-core/v2 v2.52.0
github.com/jfrog/jfrog-cli-core/v2 v2.53.0
github.com/jfrog/jfrog-cli-platform-services v1.3.0
github.com/jfrog/jfrog-cli-security v1.1.0
github.com/jfrog/jfrog-cli-security v1.2.0
github.com/jfrog/jfrog-client-go v1.40.2
github.com/jszwec/csvutil v1.10.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -137,11 +137,9 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240505160419-7173b506c6b7

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240505164307-d12abb9f140e

// replace github.com/jfrog/jfrog-cli-security => github.com/jfrog/jfrog-cli-security v1.0.6-0.20240408061620-c9b84da33d5e
// replace github.com/jfrog/jfrog-cli-security => github.com/jfrog/jfrog-cli-security v1.1.1-0.20240522121307-3e9fe2dc5e81

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ github.com/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+
github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
github.com/jfrog/archiver/v3 v3.6.0 h1:OVZ50vudkIQmKMgA8mmFF9S0gA47lcag22N13iV3F1w=
github.com/jfrog/archiver/v3 v3.6.0/go.mod h1:fCAof46C3rAXgZurS8kNRNdSVMKBbZs+bNNhPYxLldI=
github.com/jfrog/build-info-go v1.9.26 h1:1Ddc6+Ecvhc+UMnKhRVG1jGM6fYNwA49207azTBGBc8=
github.com/jfrog/build-info-go v1.9.26/go.mod h1:8T7/ajM9aGshvgpwCtXwIFpyF/R6CEn4W+/FLryNXWw=
github.com/jfrog/build-info-go v1.9.27 h1:7RWJcajqtNNbGHuYkgOLUIG7mmRKF0yxC7mvYAbdVlU=
github.com/jfrog/build-info-go v1.9.27/go.mod h1:8T7/ajM9aGshvgpwCtXwIFpyF/R6CEn4W+/FLryNXWw=
github.com/jfrog/gofrog v1.7.1 h1:ME1Meg4hukAT/7X6HUQCVSe4DNjMZACCP8aCY37EW/w=
github.com/jfrog/gofrog v1.7.1/go.mod h1:X7bjfWoQDN0Z4FQGbE91j3gbPP7Urwzm4Z8tkvrlbRI=
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-cli-core/v2 v2.52.0 h1:0+kgk9FIJCIMLlJWC2SfMU9vb9Sa0rBtH+CqxW3bsxU=
github.com/jfrog/jfrog-cli-core/v2 v2.52.0/go.mod h1:hB5R+BgmCbOoz5HZyyqEdv408rL26ej7ZSHfXGpLqmw=
github.com/jfrog/jfrog-cli-core/v2 v2.53.0 h1:qdZ1Svb1hGyRx2QviJtarhcA8eet8QtYU054nKzlhDg=
github.com/jfrog/jfrog-cli-core/v2 v2.53.0/go.mod h1:l101ZcbHy/FLieCx1xDtjONgkqsoLDNaqVT7b4KJ5OQ=
github.com/jfrog/jfrog-cli-platform-services v1.3.0 h1:IblSDZFBjL7WLRi37Ni2DmHrXJJ6ysSMxx7t41AvyDA=
github.com/jfrog/jfrog-cli-platform-services v1.3.0/go.mod h1:Ky4SDXuMeaiNP/5zMT1YSzIuXG+cNYYOl8BaEA7Awbc=
github.com/jfrog/jfrog-cli-security v1.1.0 h1:ifCjFJSa1D1pWyW/ADYPqnMkOddzkAT/WY4vHAufn1g=
github.com/jfrog/jfrog-cli-security v1.1.0/go.mod h1:086t7e/einVAGfBXxRdEGDKovWt67I6SqUb1rcpdiZc=
github.com/jfrog/jfrog-cli-security v1.2.0 h1:4lNl/bbU8qhkpnpMQqZtPlniwtM9rJXDYNEm7VsLRKs=
github.com/jfrog/jfrog-cli-security v1.2.0/go.mod h1:IbP3MiDz5gXXc2+oXSqV688uEhLrtxHapoJ14oYTV20=
github.com/jfrog/jfrog-client-go v1.40.2 h1:zdCWPPT11r0bMGnAXGhZPb3RrIINhiTFCceQABhguZ4=
github.com/jfrog/jfrog-client-go v1.40.2/go.mod h1:m3hIn12eFWk5nJH1swPRtFrjXbiiCscOpX+v/vCdmNI=
github.com/jszwec/csvutil v1.10.0 h1:upMDUxhQKqZ5ZDCs/wy+8Kib8rZR8I8lOR34yJkdqhI=
Expand Down
7 changes: 6 additions & 1 deletion utils/cliutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/jfrog/jfrog-cli-core/v2/commandsummary"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -125,7 +126,7 @@ func PrintBriefSummaryReport(success, failed int, failNoOp bool, originalErr err
func PrintDeploymentView(reader *content.ContentReader) error {
tree := artifactoryUtils.NewFileTree()
for transferDetails := new(clientutils.FileTransferDetails); reader.NextRecord(transferDetails) == nil; transferDetails = new(clientutils.FileTransferDetails) {
tree.AddFile(transferDetails.TargetPath)
tree.AddFile(transferDetails.TargetPath, "")
}
if err := reader.GetError(); err != nil {
return err
Expand Down Expand Up @@ -690,6 +691,10 @@ func CheckNewCliVersionAvailable(currentVersion string) (warningMessage string,
return
}

func GetDetailedSummary(c *cli.Context) bool {
return c.Bool("detailed-summary") || commandsummary.ShouldRecordSummary()
}

func shouldCheckLatestCliVersion() (shouldCheck bool, err error) {
if strings.ToLower(os.Getenv(JfrogCliAvoidNewVersionWarning)) == "true" {
return
Expand Down

0 comments on commit 2d277d9

Please sign in to comment.