Skip to content

Commit

Permalink
Enable logging in via environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Jan 3, 2022
1 parent c9cb0ac commit 9e957e4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,22 @@ import (
// RunLogin logs the user and asks for the 2FA code if needed
func RunLogin(ctx context.Context, streams command.Streams, hubClient *hub.Client, store credentials.Store, candidateUsername string) error {
username := candidateUsername
if username == "" {
username = os.Getenv("DOCKER_USERNAME")
}
if username == "" {
var err error
if username, err = readClearText(ctx, streams, "Username: "); err != nil {
return err
}
}
password, err := readPassword(streams)
if err != nil {
return err

password := os.Getenv("DOCKER_PASSWORD")
if password == "" {
var err error
if password, err = readPassword(streams); err != nil {
return err
}
}

token, refreshToken, err := Login(ctx, streams, hubClient, username, password)
Expand Down

0 comments on commit 9e957e4

Please sign in to comment.