Skip to content

Commit

Permalink
Enable login via env vars (for CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
spkane committed Jan 6, 2022
1 parent c9cb0ac commit b5246e6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ 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 b5246e6

Please sign in to comment.