From e34b0a2398813c852c14ca32dddeae68b39114df Mon Sep 17 00:00:00 2001 From: Michael Sverdlov Date: Mon, 28 Oct 2024 12:45:11 +0200 Subject: [PATCH] Improve missing URL errors (#2739) --- distribution/cli.go | 2 +- general/summary/cli.go | 4 ++-- general/token/cli.go | 2 +- go.mod | 4 ++-- go.sum | 9 +++++---- lifecycle/cli.go | 2 +- pipelines/cli.go | 4 ++-- utils/cliutils/commandsflags.go | 6 +++--- utils/cliutils/utils.go | 2 +- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/distribution/cli.go b/distribution/cli.go index 0410cfee2..8242da2c0 100644 --- a/distribution/cli.go +++ b/distribution/cli.go @@ -317,7 +317,7 @@ func createDistributionDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails return nil, err } if dsDetails.DistributionUrl == "" { - return nil, errors.New("the --dist-url option is mandatory") + return nil, errors.New("no JFrog Distribution URL specified, either via the --url flag or as part of the server configuration") } return dsDetails, nil } diff --git a/general/summary/cli.go b/general/summary/cli.go index 2bda48d35..5736c2a2f 100644 --- a/general/summary/cli.go +++ b/general/summary/cli.go @@ -282,10 +282,10 @@ func shouldGenerateUploadSummary() (bool, error) { func createPlatformDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, error) { platformDetails, err := cliutils.CreateServerDetailsWithConfigOffer(c, true, commonCliUtils.Platform) if err != nil { - return nil, fmt.Errorf("error creating platform details: %w", err) + return nil, fmt.Errorf("error creating JFrog Platform details: %w", err) } if platformDetails.Url == "" { - return nil, errors.New("platform URL is mandatory for access token creation") + return nil, errors.New("no JFrog Platform URL specified, either via the --url flag or as part of the server configuration") } return platformDetails, nil } diff --git a/general/token/cli.go b/general/token/cli.go index 47b7bb5f2..b13f3f188 100644 --- a/general/token/cli.go +++ b/general/token/cli.go @@ -73,7 +73,7 @@ func createPlatformDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, er return nil, err } if platformDetails.Url == "" { - return nil, errors.New("JFrog Platform URL is mandatory for access token creation") + return nil, errors.New("no JFrog Platform URL specified, either via the --url flag or as part of the server configuration") } return platformDetails, nil } diff --git a/go.mod b/go.mod index eaa862438..c3caff2f8 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/jszwec/csvutil v1.10.0 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.9.0 - github.com/testcontainers/testcontainers-go v0.33.0 + github.com/testcontainers/testcontainers-go v0.34.0 github.com/urfave/cli v1.22.16 github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c @@ -51,7 +51,7 @@ require ( github.com/cloudflare/circl v1.4.0 // indirect github.com/containerd/log v0.1.0 // indirect github.com/containerd/platforms v0.2.1 // indirect - github.com/cpuguy83/dockercfg v0.3.1 // indirect + github.com/cpuguy83/dockercfg v0.3.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect diff --git a/go.sum b/go.sum index 6f92e7e78..556422acd 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= -github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= -github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= +github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -324,6 +324,7 @@ github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -338,8 +339,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo= github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw= -github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw= -github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8= +github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo= +github.com/testcontainers/testcontainers-go v0.34.0/go.mod h1:6P/kMkQe8yqPHfPWNulFGdFHTD8HB2vLq/231xY2iPQ= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= diff --git a/lifecycle/cli.go b/lifecycle/cli.go index 4921cff23..92a7a5d0e 100644 --- a/lifecycle/cli.go +++ b/lifecycle/cli.go @@ -371,7 +371,7 @@ func createLifecycleDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, e return nil, err } if lcDetails.Url == "" { - return nil, errors.New("JFrog Platform URL is mandatory for lifecycle commands") + return nil, errors.New("no JFrog Platform URL specified, either via the --url flag or as part of the server configuration") } PlatformToLifecycleUrls(lcDetails) return lcDetails, nil diff --git a/pipelines/cli.go b/pipelines/cli.go index a053b9f98..347508672 100644 --- a/pipelines/cli.go +++ b/pipelines/cli.go @@ -1,7 +1,7 @@ package pipelines import ( - "fmt" + "errors" "github.com/jfrog/jfrog-cli-core/v2/common/commands" corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common" pipelines "github.com/jfrog/jfrog-cli-core/v2/pipelines/commands" @@ -87,7 +87,7 @@ func createPipelinesDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, e return nil, err } if plDetails.PipelinesUrl == "" { - return nil, fmt.Errorf("the --pipelines-url option is mandatory") + return nil, errors.New("no JFrog Pipelines URL specified as part of the server configuration") } return plDetails, nil } diff --git a/utils/cliutils/commandsflags.go b/utils/cliutils/commandsflags.go index a93fb65d0..957c2f6c8 100644 --- a/utils/cliutils/commandsflags.go +++ b/utils/cliutils/commandsflags.go @@ -1245,7 +1245,7 @@ var flagsMap = map[string]cli.Flag{ // Distribution's commands Flags distUrl: cli.StringFlag{ Name: url, - Usage: "[Optional] JFrog Distribution URL.` `", + Usage: "[Optional] JFrog Distribution URL. (example: https://acme.jfrog.io/distribution)` `", }, rbDryRun: cli.BoolFlag{ Name: dryRun, @@ -1320,7 +1320,7 @@ var flagsMap = map[string]cli.Flag{ // Xray's commands Flags xrUrl: cli.StringFlag{ Name: url, - Usage: "[Optional] JFrog Xray URL.` `", + Usage: "[Optional] JFrog Xray URL. (example: https://acme.jfrog.io/xray)` `", }, xrayScan: cli.StringFlag{ Name: xrayScan, @@ -1483,7 +1483,7 @@ var flagsMap = map[string]cli.Flag{ // Mission Control's commands Flags mcUrl: cli.StringFlag{ Name: url, - Usage: "[Optional] JFrog Mission Control URL.` `", + Usage: "[Optional] JFrog Mission Control URL. (example: https://acme.jfrog.io/mc)` `", }, mcAccessToken: cli.StringFlag{ Name: accessToken, diff --git a/utils/cliutils/utils.go b/utils/cliutils/utils.go index 26b2126f7..17781fe50 100644 --- a/utils/cliutils/utils.go +++ b/utils/cliutils/utils.go @@ -635,7 +635,7 @@ func CreateArtifactoryDetailsByFlags(c *cli.Context) (*coreConfig.ServerDetails, return nil, err } if artDetails.ArtifactoryUrl == "" { - return nil, errors.New("the --url option is mandatory") + return nil, errors.New("no JFrog Artifactory URL specified, either via the --url flag or as part of the server configuration") } return artDetails, nil }