-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add spec.min, spec.max to categories endpoint #1059
Conversation
"github.com/elastic/package-registry/proxymode" | ||
) | ||
|
||
func TestCategoriesWithProxyMode(t *testing.T) { |
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.
This test was moved from proxy_mode_test.go
file
04684d5
to
8a56ca2
Compare
categories.go
Outdated
if v := query.Get("capabilities"); v != "" { | ||
filter.Capabilities = strings.Split(v, ",") | ||
} | ||
|
||
if v := query.Get("spec.min"); v != "" { | ||
filter.SpecMin, err = semver.NewVersion(v) | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid 'spec.min' version '%s': %w", v, err) | ||
} | ||
} | ||
|
||
if v := query.Get("spec.max"); v != "" { | ||
filter.SpecMax, err = semver.NewVersion(v) | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid 'spec.max' version '%s': %w", v, 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.
Main changes included in this PR, adding these new filters to categories endpoint.
main_test.go
Outdated
{"/categories?capabilities=observability,security&prerelease=true", "/categories", "categories-prerelease-capabilities-observability-security.json", categoriesHandler(testLogger, indexer, testCacheTime)}, | ||
{"/categories?capabilities=none&prerelease=true", "/categories", "categories-prerelease-capabilities-none.json", categoriesHandler(testLogger, indexer, testCacheTime)}, | ||
{"/categories?spec.min=1.1.0&spec.max=2.10.0&prerelease=true", "/categories", "categories-spec-min-1.1.0-max-2.10.0.json", categoriesHandler(testLogger, indexer, testCacheTime)}, | ||
{"/categories?spec.max=2.10.0&prerelease=true", "/categories", "categories-spec-max-2.10.0.json", categoriesHandler(testLogger, indexer, testCacheTime)}, |
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.
Added new test cases for these new query parameters.
8a56ca2
to
7b04cdc
Compare
848766a
to
ae570dd
Compare
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.
Looks good, but not sure if this will work for patch versions, please add a test for this case.
…d_spec_capabilities_categories
💚 Build Succeeded
History
cc @mrodm |
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.
👍
This PR adds the query parameters
capabilities
as well asspec.min
andspec.max
in the categories endpoint as they were introduced for search endpoint in these issues:Examples:
This PR is a follow-up of #1058 . At the time of creating this PR was not merged, so this PR contains the same changes.How to test
format_version
elastic_package_registry
could be modified as: