@@ -3,13 +3,14 @@ package artifactory
3
3
import (
4
4
"errors"
5
5
"fmt"
6
- "github.com/jfrog/build-info-go/utils/pythonutils"
7
- "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
8
6
"io/ioutil"
9
7
"os"
10
8
"strconv"
11
9
"strings"
12
10
11
+ "github.com/jfrog/build-info-go/utils/pythonutils"
12
+ "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
13
+
13
14
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo"
14
15
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
15
16
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/curl"
@@ -1040,41 +1041,40 @@ func dockerPromoteCmd(c *cli.Context) error {
1040
1041
return commands .Exec (dockerPromoteCommand )
1041
1042
}
1042
1043
1043
- func containerPushCmd (c * cli.Context , containerManagerType containerutils.ContainerManagerType ) error {
1044
+ func containerPushCmd (c * cli.Context , containerManagerType containerutils.ContainerManagerType ) ( err error ) {
1044
1045
if c .NArg () != 2 {
1045
1046
return cliutils .WrongNumberOfArgumentsHandler (c )
1046
1047
}
1047
1048
artDetails , err := cliutils .CreateArtifactoryDetailsByFlags (c )
1048
1049
if err != nil {
1049
- return err
1050
+ return
1050
1051
}
1051
1052
imageTag := c .Args ().Get (0 )
1052
1053
targetRepo := c .Args ().Get (1 )
1053
1054
skipLogin := c .Bool ("skip-login" )
1054
1055
1055
1056
buildConfiguration , err := buildtools .CreateBuildConfigurationWithModule (c )
1056
1057
if err != nil {
1057
- return err
1058
+ return
1058
1059
}
1059
1060
dockerPushCommand := container .NewPushCommand (containerManagerType )
1060
1061
threads , err := cliutils .GetThreadsCount (c )
1061
1062
if err != nil {
1062
- return err
1063
+ return
1063
1064
}
1064
- dockerPushCommand .SetThreads (threads ).SetDetailedSummary (c .Bool ("detailed-summary" )).SetCmdParams ([]string {"push" , imageTag }).SetSkipLogin (skipLogin ).SetBuildConfiguration (buildConfiguration ).SetRepo (targetRepo ).SetServerDetails (artDetails ).SetImageTag (imageTag )
1065
+ printDeploymentView , detailedSummary := log .IsTerminal (), c .Bool ("detailed-summary" )
1066
+ dockerPushCommand .SetThreads (threads ).SetDetailedSummary (detailedSummary || printDeploymentView ).SetCmdParams ([]string {"push" , imageTag }).SetSkipLogin (skipLogin ).SetBuildConfiguration (buildConfiguration ).SetRepo (targetRepo ).SetServerDetails (artDetails ).SetImageTag (imageTag )
1065
1067
err = cliutils .ShowDockerDeprecationMessageIfNeeded (containerManagerType , dockerPushCommand .IsGetRepoSupported )
1066
1068
if err != nil {
1067
- return err
1069
+ return
1068
1070
}
1069
1071
err = commands .Exec (dockerPushCommand )
1070
- if err != nil {
1071
- return err
1072
- }
1073
- if dockerPushCommand .IsDetailedSummary () {
1074
- result := dockerPushCommand .Result ()
1075
- return cliutils .PrintDetailedSummaryReport (result .SuccessCount (), result .FailCount (), result .Reader (), true , false , err )
1076
- }
1077
- return nil
1072
+ result := dockerPushCommand .Result ()
1073
+
1074
+ // Cleanup.
1075
+ defer cliutils .CleanupResult (result , & err )
1076
+ err = cliutils .PrintCommandSummary (dockerPushCommand .Result (), detailedSummary , printDeploymentView , false , err )
1077
+ return
1078
1078
}
1079
1079
1080
1080
func containerPullCmd (c * cli.Context , containerManagerType containerutils.ContainerManagerType ) error {
@@ -1263,11 +1263,16 @@ func downloadCmd(c *cli.Context) error {
1263
1263
// This error is being checked latter on because we need to generate summary report before return.
1264
1264
err = progressbar .ExecWithProgress (downloadCommand , false )
1265
1265
result := downloadCommand .Result ()
1266
- err = cliutils .PrintDetailedSummaryReport (result .SuccessCount (), result .FailCount (), result .Reader (), false , cliutils .IsFailNoOp (c ), err )
1266
+ defer cliutils .CleanupResult (result , & err )
1267
+ basicSummary , err := cliutils .CreateSummaryReportString (result .SuccessCount (), result .FailCount (), cliutils .IsFailNoOp (c ), err )
1268
+ if err != nil {
1269
+ return err
1270
+ }
1271
+ err = cliutils .PrintDetailedSummaryReport (basicSummary , result .Reader (), false , err )
1267
1272
return cliutils .GetCliError (err , result .SuccessCount (), result .FailCount (), cliutils .IsFailNoOp (c ))
1268
1273
}
1269
1274
1270
- func uploadCmd (c * cli.Context ) error {
1275
+ func uploadCmd (c * cli.Context ) ( err error ) {
1271
1276
if c .NArg () > 0 && c .IsSet ("spec" ) {
1272
1277
return cliutils .PrintHelpAndReturnError ("No arguments should be sent when the spec option is used." , c )
1273
1278
}
@@ -1276,42 +1281,42 @@ func uploadCmd(c *cli.Context) error {
1276
1281
}
1277
1282
1278
1283
var uploadSpec * spec.SpecFiles
1279
- var err error
1280
1284
if c .IsSet ("spec" ) {
1281
1285
uploadSpec , err = cliutils .GetFileSystemSpec (c )
1282
1286
} else {
1283
1287
uploadSpec , err = createDefaultUploadSpec (c )
1284
1288
}
1285
1289
if err != nil {
1286
- return err
1290
+ return
1287
1291
}
1288
1292
err = spec .ValidateSpec (uploadSpec .Files , true , false )
1289
1293
if err != nil {
1290
- return err
1294
+ return
1291
1295
}
1292
1296
cliutils .FixWinPathsForFileSystemSourcedCmds (uploadSpec , c )
1293
1297
configuration , err := createUploadConfiguration (c )
1294
1298
if err != nil {
1295
- return err
1299
+ return
1296
1300
}
1297
1301
buildConfiguration , err := buildtools .CreateBuildConfigurationWithModule (c )
1298
1302
if err != nil {
1299
- return err
1303
+ return
1300
1304
}
1301
1305
retries , err := getRetries (c )
1302
1306
if err != nil {
1303
- return err
1307
+ return
1304
1308
}
1305
1309
retryWaitTime , err := getRetryWaitTime (c )
1306
1310
if err != nil {
1307
- return err
1311
+ return
1308
1312
}
1309
1313
uploadCmd := generic .NewUploadCommand ()
1310
1314
rtDetails , err := cliutils .CreateArtifactoryDetailsByFlags (c )
1311
1315
if err != nil {
1312
- return err
1316
+ return
1313
1317
}
1314
- uploadCmd .SetUploadConfiguration (configuration ).SetBuildConfiguration (buildConfiguration ).SetSpec (uploadSpec ).SetServerDetails (rtDetails ).SetDryRun (c .Bool ("dry-run" )).SetSyncDeletesPath (c .String ("sync-deletes" )).SetQuiet (cliutils .GetQuietValue (c )).SetDetailedSummary (c .Bool ("detailed-summary" )).SetRetries (retries ).SetRetryWaitMilliSecs (retryWaitTime )
1318
+ printDeploymentView , detailedSummary := log .IsTerminal (), c .Bool ("detailed-summary" )
1319
+ 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 )
1315
1320
1316
1321
if uploadCmd .ShouldPrompt () && ! coreutils .AskYesNo ("Sync-deletes may delete some artifacts in Artifactory. Are you sure you want to continue?\n " +
1317
1322
"You can avoid this confirmation message by adding --quiet to the command." , false ) {
@@ -1320,9 +1325,9 @@ func uploadCmd(c *cli.Context) error {
1320
1325
// This error is being checked latter on because we need to generate summary report before return.
1321
1326
err = progressbar .ExecWithProgress (uploadCmd , false )
1322
1327
result := uploadCmd .Result ()
1323
- err = cliutils .PrintDetailedSummaryReport (result . SuccessCount (), result . FailCount (), result . Reader (), true , cliutils . IsFailNoOp ( c ), err )
1324
-
1325
- return cliutils . GetCliError ( err , result . SuccessCount (), result . FailCount (), cliutils . IsFailNoOp ( c ))
1328
+ defer cliutils .CleanupResult (result , & err )
1329
+ err = cliutils . PrintCommandSummary ( uploadCmd . Result (), detailedSummary , printDeploymentView , cliutils . IsFailNoOp ( c ), err )
1330
+ return
1326
1331
}
1327
1332
1328
1333
func prepareCopyMoveCommand (c * cli.Context ) (* spec.SpecFiles , error ) {
0 commit comments