From d22f3a858aa4dda949be533919779ee9100277e1 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Wed, 2 Aug 2023 19:19:03 +0200 Subject: [PATCH] login: Remove the PAT message, it's in docker/cli now (#2261) Signed-off-by: Djordje Lukic --- cli/mobycli/exec.go | 2 -- cli/mobycli/pat_suggest.go | 27 --------------------------- 2 files changed, 29 deletions(-) diff --git a/cli/mobycli/exec.go b/cli/mobycli/exec.go index 91b33c5a1..4ea2eed59 100644 --- a/cli/mobycli/exec.go +++ b/cli/mobycli/exec.go @@ -117,8 +117,6 @@ func Exec(_ *cobra.Command) { displayScoutQuickViewSuggestMsgOnBuild(commandArgs) case "pull": displayScoutQuickViewSuggestMsgOnPull(commandArgs) - case "login": - displayPATSuggestMsg(commandArgs) default: } } diff --git a/cli/mobycli/pat_suggest.go b/cli/mobycli/pat_suggest.go index 65504924f..ee8c7892b 100644 --- a/cli/mobycli/pat_suggest.go +++ b/cli/mobycli/pat_suggest.go @@ -17,43 +17,16 @@ package mobycli import ( - "fmt" - "os" "strings" - "github.com/docker/cli/cli/config" "github.com/docker/docker/registry" "github.com/hashicorp/go-uuid" ) -const ( - // patSuggestMsg is a message to suggest the use of PAT (personal access tokens). - patSuggestMsg = `Logging in with your password grants your terminal complete access to your account. -For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/` -) - var ( patPrefixes = []string{"dckrp_", "dckr_pat_"} ) -// displayPATSuggestMsg displays a message suggesting users to use PATs instead of passwords to reduce scope. -func displayPATSuggestMsg(cmdArgs []string) { - if os.Getenv("DOCKER_PAT_SUGGEST") == "false" { - return - } - if !isUsingDefaultRegistry(cmdArgs) { - return - } - authCfg, err := config.LoadDefaultConfigFile(os.Stderr).GetAuthConfig(registry.IndexServer) - if err != nil { - return - } - if !isUsingPassword(authCfg.Password) { - return - } - fmt.Fprintf(os.Stderr, "\n"+patSuggestMsg+"\n") -} - func isUsingDefaultRegistry(cmdArgs []string) bool { for i := 1; i < len(cmdArgs); i++ { if strings.HasPrefix(cmdArgs[i], "-") {