verifyLoginFlags validates flags set on the command. TODO(thaJeztah); combine with verifyLoginOptions, but this requires rewrites of many tests.
(flags *pflag.FlagSet, opts loginOptions)
| 72 | // |
| 73 | // TODO(thaJeztah); combine with verifyLoginOptions, but this requires rewrites of many tests. |
| 74 | func verifyLoginFlags(flags *pflag.FlagSet, opts loginOptions) error { |
| 75 | if flags.Changed("password-stdin") || opts.password == "-" { |
| 76 | if flags.Changed("password") && opts.password != "-" { |
| 77 | return errors.New("conflicting options: cannot specify both --password and --password-stdin") |
| 78 | } |
| 79 | if !flags.Changed("username") { |
| 80 | return errors.New("the --password-stdin option requires --username to be set") |
| 81 | } |
| 82 | } |
| 83 | if flags.Changed("username") && opts.user == "" { |
| 84 | return errors.New("username is empty") |
| 85 | } |
| 86 | if flags.Changed("password") && opts.password == "" { |
| 87 | return errors.New("password is empty") |
| 88 | } |
| 89 | return nil |
| 90 | } |
| 91 | |
| 92 | // readSecretFromStdin reads the secret from r and returns it as a string. |
| 93 | // It trims terminal line-endings (LF, CRLF, or CR), which may be added when |
no outgoing calls
no test coverage detected
searching dependent graphs…