-
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 capabilities parameter in search endpoint #1054
Conversation
packages/package.go
Outdated
for _, c := range capabilities { | ||
if !util.StringsContains(p.Conditions.Elastic.Capabilities, c) { |
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.
I think it should be the other way around. For each capability in the package, there should be a matching one in the declared capabilities.
for _, c := range capabilities { | |
if !util.StringsContains(p.Conditions.Elastic.Capabilities, c) { | |
for _, requiredCapability := range p.Conditions.Elastic.Capabilities { | |
if !util.StringsContains(capabilities, requiredCapabilities) |
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.
So all the capabilities defined in the package must be present in the query in order to be added to the response ? @jsoriano
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.
Yes. Clients (aka Kibana) will indicate all the capabilities they support. We should only return packages whose required capabilities are satisfied in this list.
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.
Updated logic to do it like this.
Example in the description has also been updated taken into account this logic.
For the latter scenario, let's consider the following capabilities for a given package:
conditions:
elastic.capabilities:
- observability
- uptime
here it is shown if the package could be added to the response or not (let's consider that there are no other filters):
Query parameter | Package can be added |
---|---|
No capability in the query | yes |
capabilities=observability | no |
capabilities=observability,security | no |
capabilities=observability,uptime | yes |
capabilities=observability,uptime,security | yes |
@@ -350,6 +384,60 @@ func TestPackagesFilter(t *testing.T) { | |||
{Name: "etcd", Version: "1.0.0-rc2"}, | |||
}, | |||
}, | |||
{ | |||
Title: "non existing capabilities search", |
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.
👍
Fixes #1051
This PR adds a new filter parameter
capabilities
for the search endpoint.Current behavior when
capabilities
is defined:capabilities
query parameter.For the latter scenario, let's consider the following capabilities for a given package:
here it is shown if the package could be added to the response or not (let's consider that there are no other filters):
How to test
cd /path/to/elastic-package go mod edit -replace github.com/elastic/package-spec/v2=github.com/elastic/package-spec/v2@72f19e9 go mod tidy make build
format_version
>= 2.10.0elastic_package_registry
could be modified as: