Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pagination support for /user/teams github api with link header . #274

Merged

Conversation

toshi-miura
Copy link
Contributor

Description

Added handling of last page pointed out below to #102

Could we maybe use the Link values to make sure we only call up until the last page?

Test is done by rewriting the code with a smaller "per_page" value.

@toshi-miura toshi-miura requested a review from a team October 7, 2019 13:59
Copy link
Member

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good generally, I think there may be a few typos in the comments and I think the logs are potentially a bit too verbose, bear in mind that each of these log lines would be printed for every request

Thanks for picking this up from #102

// 1. When paging is required (Example: When the data size is 100 and the page size is 99 or less)
// 2. When it exceeds the paging frame (Example: When there is only 10 records but the second page is called with a page size of 100)

// link herder at not last page
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo I think

Suggested change
// link herder at not last page
// link header at not last page


// link herder at not last page
// <https://api.github.com/user/teams?page=1&per_page=100>; rel="prev", <https://api.github.com/user/teams?page=1&per_page=100>; rel="last", <https://api.github.com/user/teams?page=1&per_page=100>; rel="first"
// link herder at last page (doesn't exist last info)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo again?

Suggested change
// link herder at last page (doesn't exist last info)
// link header at last page (doesn't exist last info)

// link herder at last page (doesn't exist last info)
// <https://api.github.com/user/teams?page=3&per_page=10>; rel="prev", <https://api.github.com/user/teams?page=1&per_page=10>; rel="first"

logger.Printf("1:endpoint :[%s]",endpoint.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to log these? Could become very noisy in the logs as these would both be printed on every request

logger.Printf("3:doesn't exist last page info. ")
}else{
last = i
logger.Printf("3:last page index :[%d]", last)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially over-logging here

Copy link
Contributor Author

@toshi-miura toshi-miura Oct 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. How about fixing it (typo &over-logging)?

Copy link
Member

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase on master and add a note to the changelog for the entry and we can then get this merged!

@toshi-miura toshi-miura force-pushed the ap-gh-pagination-with-lastpage branch from b24a937 to ee6065d Compare October 9, 2019 19:47
======================================================
changelog note

[oauth2-proxy#274](oauth2-proxy#274)  Add github api pagination support (@toshi-miura ,@apratina)

======================================================

I didn't edit CHANGELOG.md.
Since # 102 was taken over and the change difference of CHANGELOG.md was large
@toshi-miura toshi-miura force-pushed the ap-gh-pagination-with-lastpage branch from ee6065d to 31d7b61 Compare October 9, 2019 20:35
@toshi-miura
Copy link
Contributor Author

@JoelSpeed

Please rebase on master and add a note to the changelog for the entry and we can then get this merged!

My statement was rebase, except for changes to the original author.

I didn't edit CHANGELOG.md.
Since # 102 was taken over and the change difference of CHANGELOG.md was large

providers/github.go Outdated Show resolved Hide resolved
@JoelSpeed
Copy link
Member

@toshi-miura I appreciate the diff was large, but you can add a new changelog comment now there's no merge to handle right? Since this is a functional change it needs a changelog entry before it can be merged

@toshi-miura
Copy link
Contributor Author

@JoelSpeed

it needs a changelog entry

Does it mean to add to CHANGELOG.md?
Is it like the following?

Changes since v4.0.0
#227 Add Keycloak provider (@Ofinka)
#273 Support Go 1.13 (@dio)
#274 XXXXXXXXXXXXX (@xxxx)

@JoelSpeed
Copy link
Member

Is it like the following?

Yep that's exactly what I'd like you to add, thank you :)

@toshi-miura
Copy link
Contributor Author

Can't pull the latest master CHANGELOG.md because I am a child of # 102, is that okay?

@toshi-miura
Copy link
Contributor Author

I would like to ask you what kind of cycle is it to make a release binary?
In my job, I'm wondering whether to use what I built or use this release build.

JoelSpeed
JoelSpeed previously approved these changes Oct 11, 2019
Copy link
Member

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good, has it been tested in it's latest form?

@toshi-miura
Copy link
Contributor Author

I ’m doing a manual test.
In my environment, there are only about 50 github teams, so I have the following two types of tests

  • Test with this source code (Paging logic doesn't work )
  • It's bad, but test with editing source code ("per_page": {"5"}, (Paging logic work ))

Copy link
Contributor

@loshz loshz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! small typo and then I think we're good to merge :D

CHANGELOG.md Outdated
@@ -5,6 +5,7 @@
- [#227](https://github.com/pusher/oauth2_proxy/pull/227) Add Keycloak provider (@Ofinka)
- [#273](https://github.com/pusher/oauth2_proxy/pull/273) Support Go 1.13 (@dio)
- [#275](https://github.com/pusher/oauth2_proxy/pull/275) docker: build from debian buster (@syscll)
- [#274](https://github.com/pusher/oauth2_proxy/pull/274) Supports many github teams with api pagination support (@toshi-miura ,@apratina)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [#274](https://github.com/pusher/oauth2_proxy/pull/274) Supports many github teams with api pagination support (@toshi-miura ,@apratina)
- [#274](https://github.com/pusher/oauth2_proxy/pull/274) Supports many github teams with api pagination support (@toshi-miura, @apratina)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, fixed

CHANGELOG.md Outdated Show resolved Hide resolved
Co-Authored-By: Joel Speed <Joel.speed@hotmail.co.uk>
@toshi-miura
Copy link
Contributor Author

I'm sorry to be late

JoelSpeed
JoelSpeed previously approved these changes Oct 21, 2019
Copy link
Member

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your work and patience with our reviews @toshi-miura!

@JoelSpeed JoelSpeed requested a review from loshz October 23, 2019 09:06
Copy link
Contributor

@loshz loshz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the changelog conflict is resolved this should be good to merge.

@toshi-miura
Copy link
Contributor Author

Once the changelog conflict is resolved this should be good to merge.

I resolved the conflict.

@toshi-miura toshi-miura requested a review from loshz October 24, 2019 10:28
@JoelSpeed JoelSpeed force-pushed the ap-gh-pagination-with-lastpage branch from 6d98808 to 6326660 Compare November 14, 2019 14:22
@JoelSpeed
Copy link
Member

I'm happy with this now, I've fixed up the changelog again, @syscll gonna override your requested changes as I can see this is now resolved

@JoelSpeed JoelSpeed merged commit 9fdb8ac into oauth2-proxy:master Nov 14, 2019
@toshi-miura
Copy link
Contributor Author

@JoelSpeed

Thank you for the merge.

If the release schedule is decided,
I would be grateful if you would tell the release schedule

@loshz
Copy link
Contributor

loshz commented Nov 26, 2019

We are planning to do a release in the next few weeks. We're just finalising a few other PRs.

@toshi-miura
Copy link
Contributor Author

Thank you very mush!

Jing-ze pushed a commit to Jing-ze/oauth2-proxy that referenced this pull request Nov 19, 2024
…way config (oauth2-proxy#274)

Signed-off-by: bitliu <bitliu@tencent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants