@@ -3,15 +3,16 @@ package buildtools
33import (
44 "errors"
55 "fmt"
6+ "os"
7+ "strconv"
8+ "strings"
9+
610 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
711 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup"
812 "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
913 "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
1014 "github.com/jfrog/jfrog-cli-security/utils/techutils"
1115 setupdocs "github.com/jfrog/jfrog-cli/docs/buildtools/setup"
12- "os"
13- "strconv"
14- "strings"
1516
1617 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
1718 "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
@@ -768,7 +769,7 @@ func pullCmd(c *cli.Context, image string) error {
768769 if show , err := cliutils .ShowGenericCmdHelpIfNeeded (c , c .Args (), "dockerpullhelp" ); show || err != nil {
769770 return err
770771 }
771- _ , rtDetails , _ , skipLogin , filteredDockerArgs , buildConfiguration , err := extractDockerOptionsFromArgs (c .Args ())
772+ _ , rtDetails , _ , skipLogin , _ , filteredDockerArgs , buildConfiguration , err := extractDockerOptionsFromArgs (c .Args ())
772773 if err != nil {
773774 return err
774775 }
@@ -791,24 +792,24 @@ func pushCmd(c *cli.Context, image string) (err error) {
791792 if show , err := cliutils .ShowCmdHelpIfNeeded (c , c .Args ()); show || err != nil {
792793 return err
793794 }
794- threads , rtDetails , detailedSummary , skipLogin , filteredDockerArgs , buildConfiguration , err := extractDockerOptionsFromArgs (c .Args ())
795+ threads , rtDetails , detailedSummary , skipLogin , validateSha , filteredDockerArgs , buildConfiguration , err := extractDockerOptionsFromArgs (c .Args ())
795796 if err != nil {
796797 return
797798 }
798799 printDeploymentView := log .IsStdErrTerminal ()
799- PushCommand := container .NewPushCommand (containerutils .DockerClient )
800- PushCommand .SetThreads (threads ).SetDetailedSummary (detailedSummary || printDeploymentView ).SetCmdParams (filteredDockerArgs ).SetSkipLogin (skipLogin ).SetBuildConfiguration (buildConfiguration ).SetServerDetails (rtDetails ).SetImageTag (image )
801- supported , err := PushCommand .IsGetRepoSupported ()
800+ pushCommand := container .NewPushCommand (containerutils .DockerClient )
801+ pushCommand .SetThreads (threads ).SetDetailedSummary (detailedSummary || printDeploymentView ).SetCmdParams (filteredDockerArgs ).SetSkipLogin (skipLogin ).SetBuildConfiguration (buildConfiguration ).SetServerDetails (rtDetails ).SetImageTag (image ). SetValidateSha ( validateSha )
802+ supported , err := pushCommand .IsGetRepoSupported ()
802803 if err != nil {
803804 return err
804805 }
805806 if ! supported {
806807 return cliutils .NotSupportedNativeDockerCommand ("docker-push" )
807808 }
808- err = commands .Exec (PushCommand )
809- result := PushCommand .Result ()
809+ err = commands .Exec (pushCommand )
810+ result := pushCommand .Result ()
810811 defer cliutils .CleanupResult (result , & err )
811- err = cliutils .PrintCommandSummary (PushCommand .Result (), detailedSummary , printDeploymentView , false , err )
812+ err = cliutils .PrintCommandSummary (pushCommand .Result (), detailedSummary , printDeploymentView , false , err )
812813 return
813814}
814815
@@ -824,7 +825,7 @@ func dockerNativeCmd(c *cli.Context) error {
824825 if show , err := cliutils .ShowCmdHelpIfNeeded (c , c .Args ()); show || err != nil {
825826 return err
826827 }
827- _ , _ , _ , _ , cleanArgs , _ , err := extractDockerOptionsFromArgs (c .Args ())
828+ _ , _ , _ , _ , _ , cleanArgs , _ , err := extractDockerOptionsFromArgs (c .Args ())
828829 if err != nil {
829830 return err
830831 }
@@ -833,7 +834,7 @@ func dockerNativeCmd(c *cli.Context) error {
833834}
834835
835836// Remove all the none docker CLI flags from args.
836- func extractDockerOptionsFromArgs (args []string ) (threads int , serverDetails * coreConfig.ServerDetails , detailedSummary , skipLogin bool , cleanArgs []string , buildConfig * build.BuildConfiguration , err error ) {
837+ func extractDockerOptionsFromArgs (args []string ) (threads int , serverDetails * coreConfig.ServerDetails , detailedSummary , skipLogin bool , validateSha bool , cleanArgs []string , buildConfig * build.BuildConfiguration , err error ) {
837838 cleanArgs = append ([]string (nil ), args ... )
838839 var serverId string
839840 cleanArgs , serverId , err = coreutils .ExtractServerIdFromCommand (cleanArgs )
@@ -856,6 +857,11 @@ func extractDockerOptionsFromArgs(args []string) (threads int, serverDetails *co
856857 if err != nil {
857858 return
858859 }
860+ // Extract validateSha flag
861+ cleanArgs , validateSha , err = coreutils .ExtractBoolFlagFromArgs (cleanArgs , "validate-sha" )
862+ if err != nil {
863+ return
864+ }
859865 cleanArgs , buildConfig , err = build .ExtractBuildDetailsFromArgs (cleanArgs )
860866 return
861867}
0 commit comments