userOrgLogins gets all the logins of the viewer and the organizations the viewer is a member of.
()
| 1319 | |
| 1320 | // userOrgLogins gets all the logins of the viewer and the organizations the viewer is a member of. |
| 1321 | func (c *Client) userOrgLogins() ([]loginTypes, error) { |
| 1322 | l := make([]loginTypes, 0) |
| 1323 | var v viewerLoginOrgs |
| 1324 | variables := map[string]interface{}{ |
| 1325 | "after": (*githubv4.String)(nil), |
| 1326 | } |
| 1327 | |
| 1328 | err := c.doQueryWithProgressIndicator("ViewerLoginAndOrgs", &v, variables) |
| 1329 | if err != nil { |
| 1330 | return l, err |
| 1331 | } |
| 1332 | |
| 1333 | // add the user |
| 1334 | l = append(l, loginTypes{ |
| 1335 | Login: v.Viewer.Login, |
| 1336 | Type: ViewerOwner, |
| 1337 | ID: v.Viewer.ID, |
| 1338 | }) |
| 1339 | |
| 1340 | // add orgs where the user can create projects |
| 1341 | for _, org := range v.Viewer.Organizations.Nodes { |
| 1342 | if org.ViewerCanCreateProjects { |
| 1343 | l = append(l, loginTypes{ |
| 1344 | Login: org.Login, |
| 1345 | Type: OrgOwner, |
| 1346 | ID: org.ID, |
| 1347 | }) |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | // this seem unlikely, but if there are more org logins, paginate the rest |
| 1352 | if v.Viewer.Organizations.PageInfo.HasNextPage { |
| 1353 | return c.paginateOrgLogins(l, string(v.Viewer.Organizations.PageInfo.EndCursor)) |
| 1354 | } |
| 1355 | |
| 1356 | return l, nil |
| 1357 | } |
| 1358 | |
| 1359 | // paginateOrgLogins after cursor and append them to the list of logins. |
| 1360 | func (c *Client) paginateOrgLogins(l []loginTypes, cursor string) ([]loginTypes, error) { |
no test coverage detected