(cmd *cobra.Command)
| 54 | } |
| 55 | |
| 56 | func runGetSSHKeyForUser(cmd *cobra.Command) error { |
| 57 | opts := new(gitlab.ListSSHKeysForUserOptions) |
| 58 | if cmd.Flag("page").Changed { |
| 59 | opts.Page = getFlagInt(cmd, "page") |
| 60 | } |
| 61 | if cmd.Flag("per-page").Changed { |
| 62 | opts.PerPage = getFlagInt(cmd, "per-page") |
| 63 | } |
| 64 | user := getFlagString(cmd, "user") |
| 65 | uid, err := strconv.Atoi(user) |
| 66 | if err != nil { |
| 67 | userInfo, err2 := getUserByUsername(user) |
| 68 | if err2 != nil { |
| 69 | return err2 |
| 70 | } |
| 71 | uid = userInfo.ID |
| 72 | } |
| 73 | sshKeys, err := getSSHKeysForUser(uid, opts) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | printSSHKeysOut(getFlagString(cmd, "out"), sshKeys...) |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | func runGetSSHKey(cmd *cobra.Command) error { |
| 82 | sshKeys, err := getSSHKeys() |
no test coverage detected