mirror of https://github.com/docker/cli.git
login: Add message about using PATs
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit 8d51f36ca3
)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
parent
27a19966fb
commit
11606268f8
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
configtypes "github.com/docker/cli/cli/config/types"
|
configtypes "github.com/docker/cli/cli/config/types"
|
||||||
|
"github.com/docker/cli/cli/hints"
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -19,6 +20,10 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const patSuggest = "You can log in with your password or a Personal Access " +
|
||||||
|
"Token (PAT). Using a limited-scope PAT grants better security and is required " +
|
||||||
|
"for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/"
|
||||||
|
|
||||||
// EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload.
|
// EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload.
|
||||||
//
|
//
|
||||||
// Deprecated: use [registrytypes.EncodeAuthConfig] instead.
|
// Deprecated: use [registrytypes.EncodeAuthConfig] instead.
|
||||||
|
@ -113,7 +118,11 @@ func ConfigureAuth(cli Cli, flUser, flPassword string, authconfig *registrytypes
|
||||||
if flUser = strings.TrimSpace(flUser); flUser == "" {
|
if flUser = strings.TrimSpace(flUser); flUser == "" {
|
||||||
if isDefaultRegistry {
|
if isDefaultRegistry {
|
||||||
// if this is a default registry (docker hub), then display the following message.
|
// if this is a default registry (docker hub), then display the following message.
|
||||||
fmt.Fprintln(cli.Out(), "Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.")
|
fmt.Fprintln(cli.Out(), "Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.")
|
||||||
|
if hints.Enabled() {
|
||||||
|
fmt.Fprintln(cli.Out(), patSuggest)
|
||||||
|
fmt.Fprintln(cli.Out())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
promptWithDefault(cli.Out(), "Username", authconfig.Username)
|
promptWithDefault(cli.Out(), "Username", authconfig.Username)
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package hints
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enabled returns whether cli hints are enabled or not
|
||||||
|
func Enabled() bool {
|
||||||
|
if v := os.Getenv("DOCKER_CLI_HINTS"); v != "" {
|
||||||
|
enabled, err := strconv.ParseBool(v)
|
||||||
|
if err != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return enabled
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
Loading…
Reference in New Issue