예제 #1
0
파일: github.go 프로젝트: sis-tools/drone
// Teams returns a list of all team membership for the GitHub account.
func (c *client) Teams(u *model.User) ([]*model.Team, error) {
	client := c.newClientToken(u.Token)

	opts := new(github.ListOptions)
	opts.Page = 1

	var teams []*model.Team
	for opts.Page > 0 {
		list, resp, err := client.Organizations.List("", opts)
		if err != nil {
			return nil, err
		}
		teams = append(teams, convertTeamList(list)...)
		opts.Page = resp.NextPage
	}
	return teams, nil
}
예제 #2
0
파일: helper.go 프로젝트: voxxit/drone
// GetOrgs is a helper function that returns a list of
// all orgs that a user belongs to.
func GetOrgs(client *github.Client) ([]github.Organization, error) {
	var orgs []github.Organization
	var opts = github.ListOptions{}
	opts.Page = 1

	for opts.Page > 0 {
		list, resp, err := client.Organizations.List("", &opts)
		if err != nil {
			return nil, err
		}
		orgs = append(orgs, list...)

		// increment the next page to retrieve
		opts.Page = resp.NextPage
	}
	return orgs, nil
}
예제 #3
0
파일: gphr.go 프로젝트: robertkrimen/gphr
func pages(inner func(*github.ListOptions) (*github.Response, error)) (*github.Response, error) {

	options := github.ListOptions{}

	for {

		response, err := inner(&options)
		if err != nil {
			return response, err
		}

		if response.NextPage == 0 {
			return response, nil
		}

		options.Page = response.NextPage
	}

	return nil, nil
}