Skip to content

Commit 9e957e4

Browse files
committed
Enable logging in via environment variables
1 parent c9cb0ac commit 9e957e4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/login/login.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,22 @@ import (
3939
// RunLogin logs the user and asks for the 2FA code if needed
4040
func RunLogin(ctx context.Context, streams command.Streams, hubClient *hub.Client, store credentials.Store, candidateUsername string) error {
4141
username := candidateUsername
42+
if username == "" {
43+
username = os.Getenv("DOCKER_USERNAME")
44+
}
4245
if username == "" {
4346
var err error
4447
if username, err = readClearText(ctx, streams, "Username: "); err != nil {
4548
return err
4649
}
4750
}
48-
password, err := readPassword(streams)
49-
if err != nil {
50-
return err
51+
52+
password := os.Getenv("DOCKER_PASSWORD")
53+
if password == "" {
54+
var err error
55+
if password, err = readPassword(streams); err != nil {
56+
return err
57+
}
5158
}
5259

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

0 commit comments

Comments
 (0)