-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix!: Add ListCursorOptions to Enterprise and Org code security configs
#3997
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
Open
maishivamhoo123
wants to merge
2
commits into
google:master
Choose a base branch
from
maishivamhoo123:fix-enterprise-codesec-pagination
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+334
−19
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis maybe it is better to simply extend the
gen-iterators.goto support generating iterator methods from theListEnterpriseCodeSecurityConfigurationOptions?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this kind of breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand, @alexandear - the point of using
ListOptionsandListCursorOptionsis to standardize the pagination handling. Since this endpoint uses cursor pagination, it makes sense to me to embedListCursorOptionslike we do with the other endpoints that support cursor pagination.The next release is already going to have a large number of breaking API changes, mostly related to pagination, so I think it is fine to include this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ListCursorOptionscontains more fields than the GitHub API expects. From a user's perspective, it's better to have a simplerListEnterpriseCodeSecurityConfigurationOptionswith only three fields:before,after, andper_page.ListCursorOptions:go-github/github/github.go
Lines 267 to 290 in 1732098
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, if we decide to use
ListCursorOptions, let's simply inline it instead ofListEnterpriseCodeSecurityConfigurationOptions:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexandear Sir Thank you for the suggestion.
I feel we should keep the wrapper struct as it is, rather than inlining
ListCursorOptions.The reason is that
github/gen-iterators.gorelies on the wrapper to generate the iterator. Specifically, thehasOptionsfunction iterates over theEmbedslist to find a match:https://github.com/google/go-github/blob/master/github/gen-iterators.go#L177
Since
ListCursorOptionsdefines fields directly and does not embed itself,hasOptionsreturnsfalseif we use it directly in the function signature. This causes the generator to skip creating theItermethod for this endpoint entirely.To support inlining, we would likely need to refactor the generator logic itself. Given this, and the benefit of future extensibility, I believe keeping the wrapper struct is the safer approach.
Please let me know if I have misunderstood the logic or if there is a better way to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct.
Since we had already handled direct
ListOptions, I added support forListCursorOptionsin #4007 for consistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @alexandear! I now see what you mean. 😂
Sounds good to me.