Skip to content
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
46 changes: 22 additions & 24 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package buildtools
import (
"errors"
"fmt"
"os"
"strconv"
"strings"

"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
"github.com/jfrog/jfrog-cli-security/utils/techutils"
setupdocs "github.com/jfrog/jfrog-cli/docs/buildtools/setup"
"os"
"strconv"
"strings"

"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
Expand Down Expand Up @@ -768,7 +769,7 @@ func pullCmd(c *cli.Context, image string) error {
if show, err := cliutils.ShowGenericCmdHelpIfNeeded(c, c.Args(), "dockerpullhelp"); show || err != nil {
return err
}
_, rtDetails, _, skipLogin, filteredDockerArgs, buildConfiguration, err := extractDockerOptionsFromArgs(c.Args())
_, rtDetails, _, skipLogin, _, filteredDockerArgs, buildConfiguration, err := extractDockerOptionsFromArgs(c.Args())
if err != nil {
return err
}
Expand All @@ -791,24 +792,24 @@ func pushCmd(c *cli.Context, image string) (err error) {
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
return err
}
threads, rtDetails, detailedSummary, skipLogin, filteredDockerArgs, buildConfiguration, err := extractDockerOptionsFromArgs(c.Args())
threads, rtDetails, detailedSummary, skipLogin, validateSha, filteredDockerArgs, buildConfiguration, err := extractDockerOptionsFromArgs(c.Args())
if err != nil {
return
}
printDeploymentView := log.IsStdErrTerminal()
PushCommand := container.NewPushCommand(containerutils.DockerClient)
PushCommand.SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetCmdParams(filteredDockerArgs).SetSkipLogin(skipLogin).SetBuildConfiguration(buildConfiguration).SetServerDetails(rtDetails).SetImageTag(image)
supported, err := PushCommand.IsGetRepoSupported()
pushCommand := container.NewPushCommand(containerutils.DockerClient)
pushCommand.SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetCmdParams(filteredDockerArgs).SetSkipLogin(skipLogin).SetBuildConfiguration(buildConfiguration).SetServerDetails(rtDetails).SetValidateSha(validateSha).SetImageTag(image)
supported, err := pushCommand.IsGetRepoSupported()
if err != nil {
return err
}
if !supported {
return cliutils.NotSupportedNativeDockerCommand("docker-push")
}
err = commands.Exec(PushCommand)
result := PushCommand.Result()
err = commands.Exec(pushCommand)
result := pushCommand.Result()
defer cliutils.CleanupResult(result, &err)
err = cliutils.PrintCommandSummary(PushCommand.Result(), detailedSummary, printDeploymentView, false, err)
err = cliutils.PrintCommandSummary(pushCommand.Result(), detailedSummary, printDeploymentView, false, err)
return
}

Expand All @@ -824,7 +825,7 @@ func dockerNativeCmd(c *cli.Context) error {
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
return err
}
_, _, _, _, cleanArgs, _, err := extractDockerOptionsFromArgs(c.Args())
_, _, _, _, _, cleanArgs, _, err := extractDockerOptionsFromArgs(c.Args())
if err != nil {
return err
}
Expand All @@ -833,7 +834,7 @@ func dockerNativeCmd(c *cli.Context) error {
}

// Remove all the none docker CLI flags from args.
func extractDockerOptionsFromArgs(args []string) (threads int, serverDetails *coreConfig.ServerDetails, detailedSummary, skipLogin bool, cleanArgs []string, buildConfig *build.BuildConfiguration, err error) {
func extractDockerOptionsFromArgs(args []string) (threads int, serverDetails *coreConfig.ServerDetails, detailedSummary, skipLogin bool, validateSha bool, cleanArgs []string, buildConfig *build.BuildConfiguration, err error) {
cleanArgs = append([]string(nil), args...)
var serverId string
cleanArgs, serverId, err = coreutils.ExtractServerIdFromCommand(cleanArgs)
Expand All @@ -856,6 +857,11 @@ func extractDockerOptionsFromArgs(args []string) (threads int, serverDetails *co
if err != nil {
return
}
// Extract validateSha flag
cleanArgs, validateSha, err = coreutils.ExtractBoolFlagFromArgs(cleanArgs, "validate-sha")
if err != nil {
return
}
cleanArgs, buildConfig, err = build.ExtractBuildDetailsFromArgs(cleanArgs)
return
}
Expand Down Expand Up @@ -934,17 +940,9 @@ func NpmPublishCmd(c *cli.Context) (err error) {
if npmCmd.GetXrayScan() {
commandsUtils.ConditionalUploadScanFunc = scan.ConditionalUploadDefaultScanFunc
}

var printDeploymentView, detailedSummary bool

// Deployment view and Detailed summary is not supported when using npmrc for publishing since transfer details are not available.
if npmCmd.UseNative() {
printDeploymentView, detailedSummary = false, false
} else {
printDeploymentView, detailedSummary = log.IsStdErrTerminal(), npmCmd.IsDetailedSummary()
if !detailedSummary {
npmCmd.SetDetailedSummary(printDeploymentView)
}
printDeploymentView, detailedSummary := log.IsStdErrTerminal(), npmCmd.IsDetailedSummary()
if !detailedSummary {
npmCmd.SetDetailedSummary(printDeploymentView)
}
err = commands.Exec(npmCmd)
result := npmCmd.Result()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ require (

replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250529104758-6d769a684388

//replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.2.5-0.20250514065555-2ad0e403ae04
replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.3.2-0.20250527103322-0361d8f5612d

//replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250514055103-d3d0d25f7c85
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250527091824-60a3b4b741aa

//replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250508130334-f159cff9b11a

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
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-artifactory v0.3.1 h1:0F5CgS8iR7o0PoQWcjyLWWnZVrfruNstLezzRaAb9EY=
github.com/jfrog/jfrog-cli-artifactory v0.3.1/go.mod h1:6QUvZ7US2VVUWzixh/ofn6LHhBelzLkAK+v5FqBvwZ4=
github.com/jfrog/jfrog-cli-core/v2 v2.58.7 h1:njRlkJjNZ1cvG25S/6T4h+ouI+ZRABN6xZN87UIzB/M=
github.com/jfrog/jfrog-cli-core/v2 v2.58.7/go.mod h1:ZXcipUeTTEQ/phqHdbCh4wJ5Oo4QVDxzQBREQ0J9mDc=
github.com/jfrog/jfrog-cli-artifactory v0.3.2-0.20250527103322-0361d8f5612d h1:pc0wqdFr0T3VXSk7vHjlb1IQymHq/6UNphRjIeSV2bU=
github.com/jfrog/jfrog-cli-artifactory v0.3.2-0.20250527103322-0361d8f5612d/go.mod h1:8N/wm24dayk3/+ScG3PZf8rO4yfiDpqIu5JwTwbFCnM=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250527091824-60a3b4b741aa h1:ybm7alLNcgeVRaM4a4Ma1kjzFN5jxe5yIMvdmDATEWM=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250527091824-60a3b4b741aa/go.mod h1:ZXcipUeTTEQ/phqHdbCh4wJ5Oo4QVDxzQBREQ0J9mDc=
github.com/jfrog/jfrog-cli-platform-services v1.9.0 h1:r/ETgJuMUOUu12w20ydsF6paqEaj0khH6bxMRsdNz1Y=
github.com/jfrog/jfrog-cli-platform-services v1.9.0/go.mod h1:pMZMSwhj7yA4VKyj0Skr2lObIyGpZUxNJ40DSLKXU38=
github.com/jfrog/jfrog-cli-security v1.18.0 h1:+Lf7lW7C6XfCsCd11swJicgFackEPIKOOpQTbX3cd/M=
Expand Down
15 changes: 11 additions & 4 deletions utils/cliutils/commandsflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package cliutils

import (
"fmt"
"github.com/jfrog/jfrog-cli-artifactory/cliutils/flagkit"
"sort"
"strconv"

"github.com/jfrog/jfrog-cli-artifactory/cliutils/flagkit"

commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"

Expand Down Expand Up @@ -345,6 +346,7 @@ const (
// Build tool flags
deploymentThreads = "deployment-threads"
skipLogin = "skip-login"
validateSha = "validate-sha"

// Unique docker promote flags
dockerPromotePrefix = "docker-promote-"
Expand Down Expand Up @@ -1708,6 +1710,11 @@ var flagsMap = map[string]cli.Flag{
runNative: cli.BoolFlag{
Name: runNative,
Usage: "[Default: false] Set to true if you'd like to use the native client configurations. Note: This flag would invoke native client behind the scenes, has performance implications and does not support deployment view and detailed summary` `",

},
validateSha: cli.BoolFlag{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what ist he difference between container push command and docker, dockerPush is it like OCI support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I understood was

  • DockerPush Specifically for Docker images, using the Docker CLI under the hood
  • ContainerPush - A more generic command that supports multiple container technologies, not just Docker.

Since both commands perform pushing operations that could benefit from SHA validation, it makes sense to add the flag to both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I understood was

  • DockerPush Specifically for Docker images, using the Docker CLI under the hood
  • ContainerPush - A more generic command that supports multiple container technologies, not just Docker.

Since both commands perform pushing operations that could benefit from SHA validation, it makes sense to add the flag to both.

Name: validateSha,
Usage: "[Default: false] Set to true to enable SHA validation during Docker push.` `",
},
}

Expand Down Expand Up @@ -1829,11 +1836,11 @@ var commandFlags = map[string][]string{
},
Docker: {
BuildName, BuildNumber, module, Project,
serverId, skipLogin, threads, detailedSummary, watches, repoPath, licenses, xrOutput, fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, vuln,
serverId, skipLogin, threads, detailedSummary, watches, repoPath, licenses, xrOutput, fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, vuln, validateSha,
},
DockerPush: {
BuildName, BuildNumber, module, Project,
serverId, skipLogin, threads, detailedSummary,
serverId, skipLogin, threads, detailedSummary, validateSha,
},
DockerPull: {
BuildName, BuildNumber, module, Project,
Expand All @@ -1845,7 +1852,7 @@ var commandFlags = map[string][]string{
},
ContainerPush: {
BuildName, BuildNumber, module, url, user, password, accessToken, sshPassphrase, sshKeyPath,
serverId, skipLogin, threads, Project, detailedSummary,
serverId, skipLogin, threads, Project, detailedSummary, validateSha,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the flag required here as well as in jfrog-cli-artifactory?

},
ContainerPull: {
BuildName, BuildNumber, module, url, user, password, accessToken, sshPassphrase, sshKeyPath,
Expand Down
Loading