Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into update-go-1.23.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodm committed Sep 10, 2024
2 parents 330164a + f90ac28 commit 2082727
Show file tree
Hide file tree
Showing 18 changed files with 615 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added support for content packages and its discovery fields. [#1220](https://github.com/elastic/package-registry/pull/1220)

### Deprecated

### Known Issues
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ The `/search` API endpoint has few additional query parameters. More might be ad
* `kibana.version`: Filters out all the packages which are not compatible with the given Kibana version. If it is set to `7.3.1` and
a package requires 7.4, the package will not be returned or an older compatible package will be shown.
By default this endpoint always returns only the newest compatible package.
* `category`: Filters the package by the given category. Available categories can be seend when going to `/categories` endpoint.
* `category`: Filters the package by the given category. Available categories can be seen when going to `/categories` endpoint.
* `package`: Filters by a specific package name, for example `mysql`. Returns the most recent version.
* `all`: This can be set to `true` to list all package versions. This is set to `false` by default.
* `prerelease`: This can be set to `true` to list prerelease versions of packages. Versions are considered prereleases if they are not stable according to sematic versioning, that is, if they are 0.x versions, or if they contain a prerelease tag. This is set to `false` by default.
* `prerelease`: This can be set to `true` to list prerelease versions of packages. Versions are considered prereleases if they are not stable according to semantic versioning, that is, if they are 0.x versions, or if they contain a prerelease tag. This is set to `false` by default.
* `experimental` (deprecated): This can be set to `true` to list packages considered to be experimental. This is set to `false` by default.

The different query parameters above can be combined, so `?package=mysql&kibana.version=7.3.0` will return all mysql package versions
Expand All @@ -30,7 +30,7 @@ which are compatible with `7.3.0`.

The `/categories` API endpoint has two additional query parameters.

* `prerelease`: This can be set to `true` to list prerelease versions of packages. Versions are considered prereleases if they are not stable according to sematic versioning, that is, if they are 0.x versions, or if they contain a prerelease tag. This is set to `false` by default.
* `prerelease`: This can be set to `true` to list prerelease versions of packages. Versions are considered prereleases if they are not stable according to semantic versioning, that is, if they are 0.x versions, or if they contain a prerelease tag. This is set to `false` by default.
* `experimental` (deprecated): This can be set to `true` to list categories from experimental packages. This is set to `false` by default.
* `include_policy_templates`: This can be set to `true` to include categories from policy templates. This is set to `false` by default.

Expand Down Expand Up @@ -77,7 +77,7 @@ go run .

### Single binary

You can build the `package-registry` binary usig [`mage`](https://magefile.org):
You can build the `package-registry` binary using [`mage`](https://magefile.org):
```
mage build
```
Expand Down
3 changes: 1 addition & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestEndpoints(t *testing.T) {
{"/search?prerelease=true", "/search", "search-package-prerelease.json", searchHandler(testLogger, indexer, testCacheTime)},
{"/search?prerelease=foo", "/search", "search-package-prerelease-error.txt", searchHandler(testLogger, indexer, testCacheTime)},
{"/search?category=datastore&prerelease=true", "/search", "search-category-datastore-prerelease.json", searchHandler(testLogger, indexer, testCacheTime)},
{"/search?type=content&prerelease=true", "/search", "search-content-packages.json", searchHandler(testLogger, indexer, testCacheTime)},
{"/search?type=input&prerelease=true", "/search", "search-input-packages.json", searchHandler(testLogger, indexer, testCacheTime)},
{"/search?type=input&package=integration_input&prerelease=true", "/search", "search-input-integration-package.json", searchHandler(testLogger, indexer, testCacheTime)},
{"/search?type=integration&package=integration_input&prerelease=true", "/search", "search-integration-integration-package.json", searchHandler(testLogger, indexer, testCacheTime)},
Expand Down Expand Up @@ -190,7 +191,6 @@ func TestStatics(t *testing.T) {
runEndpoint(t, test.endpoint, test.path, test.file, test.handler)
})
}

}

func TestStaticsModifiedTime(t *testing.T) {
Expand Down Expand Up @@ -588,7 +588,6 @@ func listArchivedFiles(t *testing.T, body []byte) []byte {
// Using filepath.ToSlash(f.Name) ensures that the file name has the expected format
// regardless of the OS.
listing.WriteString(fmt.Sprintf("%d %s\n", f.UncompressedSize64, filepath.ToSlash(f.Name)))

}
return listing.Bytes()
}
Expand Down
13 changes: 12 additions & 1 deletion packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type BasePackage struct {
Owner *Owner `config:"owner,omitempty" json:"owner,omitempty" yaml:"owner,omitempty"`
Categories []string `config:"categories,omitempty" json:"categories,omitempty" yaml:"categories,omitempty"`
SignaturePath string `config:"signature_path,omitempty" json:"signature_path,omitempty" yaml:"signature_path,omitempty"`
Discovery *Discovery `config:"discovery,omitempty" json:"discovery,omitempty" yaml:"discovery,omitempty"`
}

// BasePolicyTemplate is used for the package policy templates in the /search endpoint
Expand Down Expand Up @@ -160,6 +161,16 @@ type PackageElasticsearch struct {
Privileges *PackageElasticsearchPrivileges `config:"privileges,omitempty" json:"privileges,omitempty" yaml:"privileges,omitempty"`
}

// Discovery define indications for the data this package can be useful with.
type Discovery struct {
Fields []DiscoveryField `config:"fields,omitempty" json:"fields,omitempty" yaml:"fields,omitempty"`
}

// DiscoveryField defines a field used for discovery.
type DiscoveryField struct {
Name string `config:"name" json:"name" yaml:"name"`
}

type PackageElasticsearchPrivileges struct {
Cluster []string `config:"cluster,omitempty" json:"cluster,omitempty" yaml:"cluster,omitempty"`
}
Expand Down Expand Up @@ -187,7 +198,7 @@ func getDownloadPath(p Package, t string) string {
// NewPackage creates a new package instances based on the given base path.
// The path passed goes to the root of the package where the manifest.yml is.
func NewPackage(basePath string, fsBuilder FileSystemBuilder) (*Package, error) {
var p = &Package{
p := &Package{
BasePath: basePath,
fsBuilder: fsBuilder,
}
Expand Down
62 changes: 62 additions & 0 deletions packages/testdata/marshaler/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,68 @@
"/package/foo/1.0.0/docs/README.md"
]
},
{
"name": "good_content",
"title": "Good content package",
"version": "0.1.0",
"release": "beta",
"source": {
"license": "Apache-2.0"
},
"description": "This package is a dummy example for packages with the content type. These packages contain resources that are useful with data ingested by other integrations. They are not used to configure data sources.\n",
"type": "content",
"download": "/epr/good_content/good_content-0.1.0.zip",
"path": "/package/good_content/0.1.0",
"icons": [
{
"src": "/img/system.svg",
"path": "/package/good_content/0.1.0/img/system.svg",
"title": "system",
"size": "1000x1000",
"type": "image/svg+xml"
}
],
"conditions": {
"kibana": {
"version": "^8.16.0"
},
"elastic": {
"subscription": "basic"
}
},
"owner": {
"type": "elastic",
"github": "elastic/ecosystem"
},
"discovery": {
"fields": [
{
"name": "process.pid"
}
]
},
"format_version": "3.4.0",
"readme": "/package/good_content/0.1.0/docs/README.md",
"license": "basic",
"screenshots": [
{
"src": "/img/kibana-system.png",
"path": "/package/good_content/0.1.0/img/kibana-system.png",
"title": "kibana system",
"size": "1220x852",
"type": "image/png"
}
],
"assets": [
"/package/good_content/0.1.0/LICENSE.txt",
"/package/good_content/0.1.0/changelog.yml",
"/package/good_content/0.1.0/manifest.yml",
"/package/good_content/0.1.0/validation.yml",
"/package/good_content/0.1.0/docs/README.md",
"/package/good_content/0.1.0/img/kibana-system.png",
"/package/good_content/0.1.0/img/system.svg"
]
},
{
"name": "hidden",
"title": "Hidden",
Expand Down
62 changes: 62 additions & 0 deletions testdata/generated/package/good_content/0.1.0/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "good_content",
"title": "Good content package",
"version": "0.1.0",
"release": "beta",
"source": {
"license": "Apache-2.0"
},
"description": "This package is a dummy example for packages with the content type. These packages contain resources that are useful with data ingested by other integrations. They are not used to configure data sources.\n",
"type": "content",
"download": "/epr/good_content/good_content-0.1.0.zip",
"path": "/package/good_content/0.1.0",
"icons": [
{
"src": "/img/system.svg",
"path": "/package/good_content/0.1.0/img/system.svg",
"title": "system",
"size": "1000x1000",
"type": "image/svg+xml"
}
],
"conditions": {
"kibana": {
"version": "^8.16.0"
},
"elastic": {
"subscription": "basic"
}
},
"owner": {
"type": "elastic",
"github": "elastic/ecosystem"
},
"discovery": {
"fields": [
{
"name": "process.pid"
}
]
},
"format_version": "3.4.0",
"readme": "/package/good_content/0.1.0/docs/README.md",
"license": "basic",
"screenshots": [
{
"src": "/img/kibana-system.png",
"path": "/package/good_content/0.1.0/img/kibana-system.png",
"title": "kibana system",
"size": "1220x852",
"type": "image/png"
}
],
"assets": [
"/package/good_content/0.1.0/LICENSE.txt",
"/package/good_content/0.1.0/changelog.yml",
"/package/good_content/0.1.0/manifest.yml",
"/package/good_content/0.1.0/validation.yml",
"/package/good_content/0.1.0/docs/README.md",
"/package/good_content/0.1.0/img/kibana-system.png",
"/package/good_content/0.1.0/img/system.svg"
]
}
43 changes: 43 additions & 0 deletions testdata/generated/search-content-packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[
{
"name": "good_content",
"title": "Good content package",
"version": "0.1.0",
"release": "beta",
"source": {
"license": "Apache-2.0"
},
"description": "This package is a dummy example for packages with the content type. These packages contain resources that are useful with data ingested by other integrations. They are not used to configure data sources.\n",
"type": "content",
"download": "/epr/good_content/good_content-0.1.0.zip",
"path": "/package/good_content/0.1.0",
"icons": [
{
"src": "/img/system.svg",
"path": "/package/good_content/0.1.0/img/system.svg",
"title": "system",
"size": "1000x1000",
"type": "image/svg+xml"
}
],
"conditions": {
"kibana": {
"version": "^8.16.0"
},
"elastic": {
"subscription": "basic"
}
},
"owner": {
"type": "elastic",
"github": "elastic/ecosystem"
},
"discovery": {
"fields": [
{
"name": "process.pid"
}
]
}
}
]
41 changes: 41 additions & 0 deletions testdata/generated/search-package-experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,47 @@
"custom"
]
},
{
"name": "good_content",
"title": "Good content package",
"version": "0.1.0",
"release": "beta",
"source": {
"license": "Apache-2.0"
},
"description": "This package is a dummy example for packages with the content type. These packages contain resources that are useful with data ingested by other integrations. They are not used to configure data sources.\n",
"type": "content",
"download": "/epr/good_content/good_content-0.1.0.zip",
"path": "/package/good_content/0.1.0",
"icons": [
{
"src": "/img/system.svg",
"path": "/package/good_content/0.1.0/img/system.svg",
"title": "system",
"size": "1000x1000",
"type": "image/svg+xml"
}
],
"conditions": {
"kibana": {
"version": "^8.16.0"
},
"elastic": {
"subscription": "basic"
}
},
"owner": {
"type": "elastic",
"github": "elastic/ecosystem"
},
"discovery": {
"fields": [
{
"name": "process.pid"
}
]
}
},
{
"name": "hidden",
"title": "Hidden",
Expand Down
41 changes: 41 additions & 0 deletions testdata/generated/search-package-prerelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,47 @@
"custom"
]
},
{
"name": "good_content",
"title": "Good content package",
"version": "0.1.0",
"release": "beta",
"source": {
"license": "Apache-2.0"
},
"description": "This package is a dummy example for packages with the content type. These packages contain resources that are useful with data ingested by other integrations. They are not used to configure data sources.\n",
"type": "content",
"download": "/epr/good_content/good_content-0.1.0.zip",
"path": "/package/good_content/0.1.0",
"icons": [
{
"src": "/img/system.svg",
"path": "/package/good_content/0.1.0/img/system.svg",
"title": "system",
"size": "1000x1000",
"type": "image/svg+xml"
}
],
"conditions": {
"kibana": {
"version": "^8.16.0"
},
"elastic": {
"subscription": "basic"
}
},
"owner": {
"type": "elastic",
"github": "elastic/ecosystem"
},
"discovery": {
"fields": [
{
"name": "process.pid"
}
]
}
},
{
"name": "hidden",
"title": "Hidden",
Expand Down
Loading

0 comments on commit 2082727

Please sign in to comment.