fix!: Add ListCursorOptions to Enterprise and Org code security configs#3997
fix!: Add ListCursorOptions to Enterprise and Org code security configs#3997maishivamhoo123 wants to merge 2 commits intogoogle:masterfrom
ListCursorOptions to Enterprise and Org code security configs#3997Conversation
| // A cursor, as given in the Link header. If specified, the query only searches for security configurations before this cursor. | ||
| Before string `url:"before,omitempty"` | ||
|
|
||
| // A cursor, as given in the Link header. If specified, the query only searches for security configurations after this cursor. | ||
| After string `url:"after,omitempty"` | ||
|
|
||
| // For paginated result sets, the number of results to include per page. | ||
| PerPage int `url:"per_page,omitempty"` |
There was a problem hiding this comment.
@gmlewis maybe it is better to simply extend the gen-iterators.go to support generating iterator methods from the ListEnterpriseCodeSecurityConfigurationOptions?
There was a problem hiding this comment.
I don't like this kind of breaking change.
There was a problem hiding this comment.
I'm not sure I understand, @alexandear - the point of using ListOptions and ListCursorOptions is to standardize the pagination handling. Since this endpoint uses cursor pagination, it makes sense to me to embed ListCursorOptions like 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.
ListCursorOptions contains more fields than the GitHub API expects. From a user's perspective, it's better to have a simpler ListEnterpriseCodeSecurityConfigurationOptions with only three fields: before, after, and per_page.
ListCursorOptions:
Lines 267 to 290 in 1732098
There was a problem hiding this comment.
Anyway, if we decide to use ListCursorOptions, let's simply inline it instead of ListEnterpriseCodeSecurityConfigurationOptions:
func (s *EnterpriseService) ListCodeSecurityConfigurations(ctx context.Context, enterprise string, opts *ListCursorOptions) ([]*CodeSecurityConfiguration, *Response, error) {There was a problem hiding this comment.
@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.go relies on the wrapper to generate the iterator. Specifically, the hasOptions function iterates over the Embeds list to find a match:
https://github.com/google/go-github/blob/master/github/gen-iterators.go#L177
Since ListCursorOptions defines fields directly and does not embed itself, hasOptions returns false if we use it directly in the function signature. This causes the generator to skip creating the Iter method 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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3997 +/- ##
==========================================
+ Coverage 93.52% 93.54% +0.01%
==========================================
Files 207 207
Lines 17597 17648 +51
==========================================
+ Hits 16458 16509 +51
Misses 938 938
Partials 201 201 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ListCursorOptions to Enterprise and Org code security configs
This PR updates
ListEnterpriseCodeSecurityConfigurationOptionsandListCodeSecurityConfigurationRepositoriesOptionsto embedListCursorOptions.Changes:
Before,After,PerPage) withListCursorOptionsembedding.Reason:
These endpoints support cursor-based pagination. Explicitly embedding
ListCursorOptionsensures the library generates the correctItermethods, preventing infinite loops and aligning with the GitHub API.Issue Related #3976