-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
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}) |
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.
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 | |||
} |
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.
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 | |||
} |
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.
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>
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
name
query parameter to/tagcategories
list./tagcategories/:id/tags
subresource, with optionalname
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.