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

Return experimental packages on searches with prerelease=true #894

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bugfixes

* Return experimental packages on searches with `prerelease=true` and without
`experimental=true`. [#894](https://github.com/elastic/package-registry/pull/894)

### Added

### Deprecated
Expand Down
2 changes: 1 addition & 1 deletion packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (f *Filter) Apply(ctx context.Context, packages Packages) Packages {
var packagesList Packages
for _, p := range packages {
// Skip experimental packages if flag is not specified.
if p.Release == ReleaseExperimental && !f.Experimental {
if p.Release == ReleaseExperimental && !f.Prerelease {
continue
}

Expand Down
21 changes: 8 additions & 13 deletions packages/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ func TestPackagesFilter(t *testing.T) {
Prerelease: true,
},
Expected: []filterTestPackage{
// FIXME: This package should be returned.
// {Name: "mysql", Version: "0.9.0"},
{Name: "mysql", Version: "0.9.0"},
},
},
{
Expand All @@ -131,8 +130,11 @@ func TestPackagesFilter(t *testing.T) {
PackageName: "logstash",
},
Expected: []filterTestPackage{
// FIXME: This package should be returned.
// {Name: "logstash", Version: "1.1.0"},
// It is ok to don't return the following package, these cases
// should be released without experimental flag as they have
// GA versions. It would be returned in any case if
// `prerelease=true` is used, as in the following test.
// {Name: "logstash", Version: "1.1.0"}
},
},
{
Expand All @@ -142,8 +144,7 @@ func TestPackagesFilter(t *testing.T) {
Prerelease: true,
},
Expected: []filterTestPackage{
// FIXME: This package should be returned.
// {Name: "logstash", Version: "1.1.0"},
{Name: "logstash", Version: "1.1.0"},
},
},
{
Expand All @@ -163,8 +164,6 @@ func TestPackagesFilter(t *testing.T) {
{Name: "apache", Version: "1.0.0"},
{Name: "nginx", Version: "2.0.0"},
{Name: "redisenterprise", Version: "1.0.0"},
// FIXME: This package should be returned.
// {Name: "logstash", Version: "1.1.0"},
},
},
{
Expand All @@ -173,11 +172,7 @@ func TestPackagesFilter(t *testing.T) {
AllVersions: true,
Prerelease: true,
},
Expected: removeFilterTestPackages(filterTestPackages,
// FIXME: These packages should be also returned.
filterTestPackage{Name: "mysql", Version: "0.9.0"},
filterTestPackage{Name: "logstash", Version: "1.1.0"},
),
Expected: filterTestPackages,
},
{
Title: "apache package default search",
Expand Down
2 changes: 1 addition & 1 deletion testdata/generated/categories-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{
"id": "monitoring",
"title": "Monitoring",
"count": 2
"count": 3
},
{
"id": "web",
Expand Down
21 changes: 21 additions & 0 deletions testdata/generated/search-package-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,27 @@
"custom"
]
},
{
"name": "traces",
"title": "Not actually APM",
"version": "1.0.0",
"release": "experimental",
"description": "Not actually APM",
"type": "integration",
"download": "/epr/traces/traces-1.0.0.zip",
"path": "/package/traces/1.0.0",
"conditions": {
"kibana": {
"version": "~7.x.x"
}
},
"owner": {
"github": "github.com/elastic/not-apm"
},
"categories": [
"monitoring"
]
},
{
"name": "reference",
"title": "Reference package",
Expand Down
18 changes: 9 additions & 9 deletions testdata/generated/storage-indexer/categories-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@
{
"id": "containers",
"title": "Containers",
"count": 3
"count": 4
},
{
"id": "custom",
"title": "Custom",
"count": 8
"count": 9
},
{
"id": "datastore",
"title": "Datastore",
"count": 10
"count": 12
},
{
"id": "elastic_stack",
"title": "Elastic Stack",
"count": 6
"count": 7
},
{
"id": "google_cloud",
Expand All @@ -47,7 +47,7 @@
{
"id": "kubernetes",
"title": "Kubernetes",
"count": 2
"count": 3
},
{
"id": "message_queue",
Expand All @@ -57,12 +57,12 @@
{
"id": "monitoring",
"title": "Monitoring",
"count": 7
"count": 8
},
{
"id": "network",
"title": "Network",
"count": 23
"count": 39
},
{
"id": "os_system",
Expand All @@ -77,11 +77,11 @@
{
"id": "security",
"title": "Security",
"count": 77
"count": 101
},
{
"id": "web",
"title": "Web",
"count": 18
"count": 20
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,45 @@
],
"signature_path": "/epr/cockroachdb/cockroachdb-0.2.0.zip.sig"
},
{
"name": "elasticsearch",
"title": "Elasticsearch",
"version": "0.2.0",
"release": "experimental",
"description": "Elasticsearch Integration",
"type": "integration",
"download": "/epr/elasticsearch/elasticsearch-0.2.0.zip",
"path": "/package/elasticsearch/0.2.0",
"icons": [
{
"src": "/img/logo_elasticsearch.svg",
"path": "/package/elasticsearch/0.2.0/img/logo_elasticsearch.svg",
"title": "logo elasticsearch",
"size": "32x32",
"type": "image/svg+xml"
}
],
"policy_templates": [
{
"name": "elasticsearch",
"title": "Elasticsearch logs and metrics",
"description": "Collect logs and metrics from Elasticsearch instances"
}
],
"conditions": {
"kibana": {
"version": "^7.15.0"
}
},
"owner": {
"github": "elastic/integrations"
},
"categories": [
"elastic_stack",
"datastore"
],
"signature_path": "/epr/elasticsearch/elasticsearch-0.2.0.zip.sig"
},
{
"name": "microsoft_sqlserver",
"title": "Microsoft SQL Server",
Expand Down Expand Up @@ -436,6 +475,45 @@
],
"signature_path": "/epr/postgresql/postgresql-1.2.0.zip.sig"
},
{
"name": "prometheus",
"title": "Prometheus Metrics",
"version": "0.7.0",
"release": "experimental",
"description": "Collect metrics from Prometheus servers with Elastic Agent.",
"type": "integration",
"download": "/epr/prometheus/prometheus-0.7.0.zip",
"path": "/package/prometheus/0.7.0",
"icons": [
{
"src": "/img/logo_prometheus.svg",
"path": "/package/prometheus/0.7.0/img/logo_prometheus.svg",
"title": "logo prometheus",
"size": "32x32",
"type": "image/svg+xml"
}
],
"policy_templates": [
{
"name": "prometheus",
"title": "Prometheus metrics",
"description": "Collect metrics from Prometheus instances"
}
],
"conditions": {
"kibana": {
"version": "^7.14.0 || ^8.0.0"
}
},
"owner": {
"github": "elastic/integrations"
},
"categories": [
"monitoring",
"datastore"
],
"signature_path": "/epr/prometheus/prometheus-0.7.0.zip.sig"
},
{
"name": "redis",
"title": "Redis",
Expand Down
Loading