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

Support pagination in list catalog #201

Merged
merged 1 commit into from
Aug 26, 2019
Merged

Conversation

rmalpani-uber
Copy link
Contributor

  • Tagserver now sends list and listRepositories in paginated format
  • TagClient support list and listRepositories with pagination
  • registryoverride support pagination for catalog listing
  • Test cases

@@ -484,29 +470,29 @@ func buildPaginationOptions(u *url.URL) ([]backend.ListOption, error) {
func buildPaginationResponse(u *url.URL, continuationToken string,
result []string) (interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Returning interface{} is dangerous and cause runtime issues. Only do it when you absolutely have to and comment on the return types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initial, buildPaginationResponse was sending different responses based on argument, not anymore. Make sense to not send interface now.

@@ -54,6 +58,21 @@ type singleClient struct {
tls *tls.Config
}

// Request for ListWithPagination.
type ListRequest struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we move ListRequest to tagmodels too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is request from consumers of tagclient. Models are interaction between tagserver and tagclient.

}

// Response from ListWithPagination.
type ListResponse struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to remove this struct and just use tagsmodels.ListResponse? Having two similar structs can be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tagclient.ListResposne is internal struct to transfer data between different modules. tagmodels.ListResponse is http response though and contains field that are not relevant to tagclient.ListResponse. Let me rename tagclient.ListResponse to avoid confusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

imo having two similar structs is more confusing then a struct containing irrelevant fields. All you need is GetNames, GetOffset and GetNextURL ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Response from tagserver contains next in url format
e.g "/list/[a-z][A-Z][0-9]*?limt=&offset="
compared tagclient.ListWithPagination that contains offset(read next) as token-string. The reason is to hide it from the caller of tagclient.ListWithPagination. I can consolidate the two struct with Next field being interpreted as 2 different things based on the context?

@evelynl94
Copy link
Collaborator

It would be nice to document the behaviors of /_catalog and /tags/list in the description.

@rmalpani-uber
Copy link
Contributor Author

It would be nice to document the behaviors of /_catalog and /tags/list in the description.

yep


// List Response with pagination. Models tagserver reponse to list and
// listRepository.
type ListResponse struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm still leaning towards unifying the two response structs. Also, looks like we parse the responses twice here to get offset and next. Is it possible to have ListResponse.GetOffset() and ListResponse.GetNext()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are parsing twice for the reason above.

Copy link
Collaborator

@evelynl94 evelynl94 left a comment

Choose a reason for hiding this comment

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

thanks!

@evelynl94
Copy link
Collaborator

actually this test is failing test_proxy_list_repository_tags, could you fix that too?

+ Tagserver now sends list and listRepositories in paginated format
+ TagClient support list and listRepositories with pagination
+ registryoverride support pagination for catalog listing
+ Test cases
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.

2 participants