mirror of https://github.com/docker/cli.git
registry: warn of DOCKER_AUTH_CONFIG usage in login and logout
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
This commit is contained in:
parent
dec07e6fdf
commit
ccd5bd8d57
|
|
@ -110,6 +110,9 @@ func runLogin(ctx context.Context, dockerCLI command.Cli, opts loginOptions) err
|
|||
if err := verifyLoginOptions(dockerCLI, &opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
maybePrintEnvAuthWarning(dockerCLI)
|
||||
|
||||
var (
|
||||
serverAddress string
|
||||
msg string
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ func NewLogoutCommand(dockerCli command.Cli) *cobra.Command {
|
|||
}
|
||||
|
||||
func runLogout(ctx context.Context, dockerCLI command.Cli, serverAddress string) error {
|
||||
maybePrintEnvAuthWarning(dockerCLI)
|
||||
|
||||
var isDefaultRegistry bool
|
||||
|
||||
if serverAddress == "" {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package registry
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/config/configfile"
|
||||
"github.com/docker/cli/internal/tui"
|
||||
)
|
||||
|
||||
// maybePrintEnvAuthWarning if the `DOCKER_AUTH_CONFIG` environment variable is
|
||||
// set this function will output a warning to stdErr
|
||||
func maybePrintEnvAuthWarning(out command.Streams) {
|
||||
if os.Getenv(configfile.DockerEnvConfigKey) != "" {
|
||||
tui.NewOutput(out.Err()).
|
||||
PrintWarning("%[1]s is set and takes precedence.\nUnset %[1]s to restore the CLI auth behaviour.\n", configfile.DockerEnvConfigKey)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue