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

✨ TagCategory API improvements #291

Merged
merged 1 commit into from
Apr 13, 2023
Merged

Conversation

mansam
Copy link
Collaborator

@mansam mansam commented Apr 7, 2023

  • Adds optional name query parameter to /tagcategories list.
  • Adds /tagcategories/:id/tags subresource, with optional name query parameter to filter.

These name query parameters are a case sensitive exact match, which will result in the list containing either one or no entries.

@mansam mansam requested a review from jortel April 7, 2023 21:37
addon/tag.go Outdated
@@ -59,7 +59,8 @@ func (h *Tag) Delete(r *api.Tag) (err error) {
// Find by name and type.
func (h *Tag) Find(name string, category uint) (r *api.Tag, found bool, err error) {
list := []api.Tag{}
err = h.client.Get(api.TagsRoot, &list)
path := Path(api.TagCategoryTagsRoot).Inject(Params{api.ID: r.ID})
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be?

path := Path(api.TagCategoryTagsRoot).Inject(Params{api.ID: category})

@@ -59,7 +59,8 @@ func (h *Tag) Delete(r *api.Tag) (err error) {
// Find by name and type.
func (h *Tag) Find(name string, category uint) (r *api.Tag, found bool, err error) {
list := []api.Tag{}
err = h.client.Get(api.TagsRoot, &list)
path := Path(api.TagCategoryTagsRoot).Inject(Params{api.ID: r.ID})
err = h.client.Get(path, &list, Param{Key: api.Name, Value: name})
if err != nil {
return
}
Copy link
Contributor

@jortel jortel Apr 10, 2023

Choose a reason for hiding this comment

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

Can't the loop and search following this be replaced with:

if len(list) > 0 {
    found = true
    r = &list[0]
}

@@ -143,7 +144,7 @@ func (h *TagCategory) Delete(r *api.TagCategory) (err error) {
// Find by name.
func (h *TagCategory) Find(name string) (r *api.TagCategory, found bool, err error) {
list := []api.TagCategory{}
err = h.client.Get(api.TagCategoriesRoot, &list)
err = h.client.Get(api.TagCategoriesRoot, &list, Param{Key: api.Name, Value: name})
if err != nil {
return
}
Copy link
Contributor

@jortel jortel Apr 10, 2023

Choose a reason for hiding this comment

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

Can't the loop and search following this be replaced with:

if len(list) > 0 {
    found = true
    r = &list[0]
}

Signed-off-by: Sam Lucidi <slucidi@redhat.com>
Copy link
Contributor

@jortel jortel left a comment

Choose a reason for hiding this comment

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

LGTM

@mansam mansam merged commit 210c382 into konveyor:main Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants