-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feat: basic implementation for search for auto-completion api #112
Conversation
guacamole
commented
Mar 5, 2022
- This is the most basic implementation for auto-complete api
- We are using index with text_pattern_ops
- Optimisations to come as we test and integrate it with frontend
@@ -829,3 +829,15 @@ func (r *registry) ApiVersion(ctx echo.Context) error { | |||
|
|||
return ctx.String(http.StatusOK, "OK\n") | |||
} | |||
|
|||
func (r *registry) GetImageNamespace(ctx echo.Context) error { | |||
searchQuery := ctx.QueryParam("search_query") |
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.
@guacamole can we check for emptiness here?
router/router.go
Outdated
@@ -114,4 +114,6 @@ func Docker(group *echo.Group, reg registry.Registry) { | |||
|
|||
// GET /v2/_catalog | |||
group.Add(http.MethodGet, Catalog, reg.Catalog) | |||
group.Add(http.MethodGet, "/search", reg.GetImageNamespace) |
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.
lets put this in a const like we did with Catalog and the path can be /v2/catalog/search
@@ -114,4 +114,6 @@ func Docker(group *echo.Group, reg registry.Registry) { | |||
|
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.
Also worth noting that the Function here called Docker can totally be called Extensions
store/postgres/container_image.go
Outdated
defer cancel() | ||
rows, err := p.conn.Query(childCtx, queries.GetImageNamespace, "%"+search+"%") | ||
if err != nil { | ||
return nil, err |
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.
wrap this error with a little description
store/postgres/container_image.go
Outdated
for rows.Next() { | ||
var ns string | ||
if err := rows.Scan(&ns); err != nil { | ||
return nil, err |
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.
also 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.
LGTM 🥇 🥇 🥇