From 8e118077b14a144d68cfbdf8154d6f78bf8715b2 Mon Sep 17 00:00:00 2001 From: Michael Sverdlov Date: Fri, 13 Dec 2024 11:41:34 +0200 Subject: [PATCH] Login command - Ensure JFrog Platform URL input is non-empty before proceeding (#1308) * Improve upload archive progress bar Signed-off-by: Michael Sverdlov * Improve upload archive progress bar Signed-off-by: Michael Sverdlov * Improve upload archive progress bar Signed-off-by: Michael Sverdlov --------- Signed-off-by: Michael Sverdlov --- general/login/login.go | 20 +++++++++++--------- go.mod | 4 ++-- go.sum | 7 ++++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/general/login/login.go b/general/login/login.go index 589651987..9bd4b47e0 100644 --- a/general/login/login.go +++ b/general/login/login.go @@ -1,6 +1,7 @@ package login import ( + "fmt" "github.com/jfrog/jfrog-cli-core/v2/common/commands" "github.com/jfrog/jfrog-cli-core/v2/general" "github.com/jfrog/jfrog-cli-core/v2/utils/config" @@ -32,21 +33,22 @@ func (lc *LoginCommand) Run() error { } func newConfLogin() error { - platformUrl, err := promptPlatformUrl() - if err != nil { - return err - } + platformUrl := promptPlatformUrl() newServer := config.ServerDetails{Url: platformUrl} return general.ConfigServerWithDeducedId(&newServer, true, true) } -func promptPlatformUrl() (string, error) { +func promptPlatformUrl() string { var platformUrl string - ioutils.ScanFromConsole("Enter your JFrog Platform URL", &platformUrl, "") - if platformUrl == "" { - return "", errorutils.CheckErrorf("providing JFrog Platform URL is mandatory") + // Loop until a non-empty platformUrl is entered + for { + ioutils.ScanFromConsole("Enter your JFrog Platform URL", &platformUrl, "") + if platformUrl != "" { + break + } + fmt.Println("The JFrog Platform URL cannot be empty. Please try again.") } - return platformUrl, nil + return platformUrl } func existingConfLogin(configurations []*config.ServerDetails) error { diff --git a/go.mod b/go.mod index 678f6c67b..e9de07281 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 github.com/google/uuid v1.6.0 github.com/gookit/color v1.5.4 - github.com/jedib0t/go-pretty/v6 v6.6.1 + github.com/jedib0t/go-pretty/v6 v6.6.3 github.com/jfrog/build-info-go v1.10.6 github.com/jfrog/gofrog v1.7.6 github.com/jfrog/jfrog-client-go v1.48.3 @@ -19,7 +19,7 @@ require ( github.com/manifoldco/promptui v0.9.0 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c github.com/spf13/viper v1.19.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/urfave/cli v1.22.16 github.com/vbauerster/mpb/v8 v8.8.3 golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f diff --git a/go.sum b/go.sum index f7a21ec88..74666008c 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jedib0t/go-pretty/v6 v6.6.1 h1:iJ65Xjb680rHcikRj6DSIbzCex2huitmc7bDtxYVWyc= -github.com/jedib0t/go-pretty/v6 v6.6.1/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= +github.com/jedib0t/go-pretty/v6 v6.6.3 h1:nGqgS0tgIO1Hto47HSaaK4ac/I/Bu7usmdD3qvs0WvM= +github.com/jedib0t/go-pretty/v6 v6.6.3/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI= github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw= github.com/jfrog/build-info-go v1.10.6 h1:zH1ZhXlVfi5DlFyunygHjrdOcnv5qxfeLqmsfD4+lc4= @@ -191,8 +191,9 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 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=