(dockerCLI command.Streams, opts *loginOptions)
| 122 | } |
| 123 | |
| 124 | func verifyLoginOptions(dockerCLI command.Streams, opts *loginOptions) error { |
| 125 | if opts.password == "-" { |
| 126 | opts.password = "" |
| 127 | opts.passwordStdin = true |
| 128 | } |
| 129 | |
| 130 | if opts.password != "" { |
| 131 | _, _ = fmt.Fprintln(dockerCLI.Err(), "WARNING! Using --password via the CLI is insecure. Use --password-stdin.") |
| 132 | } |
| 133 | |
| 134 | if opts.passwordStdin { |
| 135 | if opts.user == "" { |
| 136 | return errors.New("username is empty") |
| 137 | } |
| 138 | p, err := readSecretFromStdin(dockerCLI.In()) |
| 139 | if err != nil { |
| 140 | return err |
| 141 | } |
| 142 | if strings.TrimSpace(p) == "" { |
| 143 | return errors.New("password is empty") |
| 144 | } |
| 145 | opts.password = p |
| 146 | } |
| 147 | return nil |
| 148 | } |
| 149 | |
| 150 | func runLogin(ctx context.Context, dockerCLI command.Cli, opts loginOptions) error { |
| 151 | if err := verifyLoginOptions(dockerCLI, &opts); err != nil { |
no test coverage detected
searching dependent graphs…