Merge pull request #1008 from n4ss/revert-unencrypted-prompt

Revert unencryted storage warning prompt
This commit is contained in:
Sebastiaan van Stijn 2018-04-18 00:01:13 -07:00 committed by GitHub
commit 8618838bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 16 deletions

View File

@ -55,22 +55,15 @@ func NewLoginCommand(dockerCli command.Cli) *cobra.Command {
return cmd return cmd
} }
// unencryptedPrompt prompts the user to find out whether they want to continue // displayUnencryptedWarning warns the user when using an insecure credential storage.
// with insecure credential storage. If stdin is not a terminal, we assume they // After a deprecation period, user will get prompted if stdin and stderr are a terminal.
// want it (sadly), because people may have been scripting insecure logins and // Otherwise, we'll assume they want it (sadly), because people may have been scripting
// we don't want to break them. Maybe they'll see the warning in their logs and // insecure logins and we don't want to break them. Maybe they'll see the warning in their
// fix things. // logs and fix things.
func unencryptedPrompt(dockerCli command.Streams, filename string) error { func displayUnencryptedWarning(dockerCli command.Streams, filename string) error {
fmt.Fprintln(dockerCli.Err(), fmt.Sprintf(unencryptedWarning, filename)) _, err := fmt.Fprintln(dockerCli.Err(), fmt.Sprintf(unencryptedWarning, filename))
if dockerCli.In().IsTerminal() { return err
if command.PromptForConfirmation(dockerCli.In(), dockerCli.Out(), "") {
return nil
}
return errors.Errorf("User refused unencrypted credentials storage.")
}
return nil
} }
type isFileStore interface { type isFileStore interface {
@ -146,7 +139,7 @@ func runLogin(dockerCli command.Cli, opts loginOptions) error { //nolint: gocycl
store, isDefault := creds.(isFileStore) store, isDefault := creds.(isFileStore)
if isDefault { if isDefault {
err = unencryptedPrompt(dockerCli, store.GetFilename()) err = displayUnencryptedWarning(dockerCli, store.GetFilename())
if err != nil { if err != nil {
return err return err
} }