Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance login prompt #752

Merged
merged 2 commits into from
Jan 31, 2022
Merged

Conversation

fahedouch
Copy link
Member

@fahedouch fahedouch commented Jan 28, 2022

replace #641 ( thanks @simorgh1 )

Signed-off-by: fahed dorgaa fahed.dorgaa@gmail.com

@fahedouch fahedouch marked this pull request as draft January 28, 2022 18:05
@fahedouch fahedouch marked this pull request as ready for review January 28, 2022 18:39
@fahedouch fahedouch force-pushed the prompt-username-login branch 2 times, most recently from 7890f57 to d3d332c Compare January 28, 2022 18:40
@simorgh1
Copy link

Not entering the username raises the following error
FATA[0002] error reading username: unexpected newline
instead of the validation error: username is required

I had the same issue when assigning the username,
options.username = username

By not entering username, the value will be a newline and option.username raises the above error.

@AkihiroSuda
Copy link
Member

Please squash

if term.IsTerminal(syscall.Stdin) {
fd = os.Stdin
} else {
tty, err := os.Open("/dev/tty")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t we just read stdin even when it is not a terminal?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to know the use case that one would pass username and password by stdin and why, then password alone has such case, because of secret that is passed but username as stdin? docker login has only password stdin option.
cat secret-password | docker login --username foo --password-stdin

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding username to stdin is not intuitive without username-stdin which is rarely used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, readUsername() should return an error when stdin is not a terminal?
I don't think we have to open /dev/tty here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a follow-up commit to avoid /dev/tty

Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda merged commit ce3f38a into containerd:master Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants