diff options
| author | mo khan <mo@mokhan.ca> | 2024-06-05 12:11:33 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2024-06-05 12:11:33 -0600 |
| commit | 441696da61af739f8cdadf122e7a669452094fbb (patch) | |
| tree | fbbaf95aa2d6abe2fb43bd88eb759a28c7e9512f | |
| parent | 9d425f05f2eb8d16a89d2038c316be8209d17da9 (diff) | |
Extract EachIssue function to allow support for paginating through results
| -rw-r--r-- | cmd/stanuki/main.go | 5 | ||||
| -rw-r--r-- | pkg/gitlab/group.go | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/cmd/stanuki/main.go b/cmd/stanuki/main.go index 7288c7f..9b4fca3 100644 --- a/cmd/stanuki/main.go +++ b/cmd/stanuki/main.go @@ -11,8 +11,7 @@ import ( func main() { gl := gitlab.New(context.TODO(), env.Fetch("GITLAB_TOKEN", "")) - issues := gl.Group(9970).Issues() - for _, issue := range issues { + gl.Group(9970).EachIssue(func(issue *gitlab.Issue) { fmt.Printf("%v: %v\n", issue.ID, issue.Title) - } + }) } diff --git a/pkg/gitlab/group.go b/pkg/gitlab/group.go index ff5dfc3..1969610 100644 --- a/pkg/gitlab/group.go +++ b/pkg/gitlab/group.go @@ -20,9 +20,11 @@ func NewGroup(gl *GitLab, id int) *Group { } } -func (group *Group) Issues() []Issue { +func (group *Group) EachIssue(fn func(*Issue)) { response := group.api.Get(group.url + "/issues") defer response.Body.Close() - return x.Must(FromIssues(response.Body)) + for _, issue := range x.Must(FromIssues(response.Body)) { + fn(&issue) + } } |
