-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] update getPackageInfo to handle uploaded packages #83854
[Fleet] update getPackageInfo to handle uploaded packages #83854
Conversation
Pinging @elastic/ingest-management (Team:Ingest Management) |
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.
Yay! Thanks for adding the tests. Didn't get to run locally, but LGTM. Left some comments but nothing that can't be addressed later.
export type PackageInfo = | ||
| Installable< | ||
// remove the properties we'll be altering/replacing from the base type | ||
Omit<RegistryPackage, keyof PackageAdditions> & |
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.
Not able to check right now, but does this not work as Omit<RegistryPackage|ArchivePackage
?
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'm not exactly sure why, but it breaks a type like this:
.
The error is:
Type '{ name: string; title: string; version: string; latestVersion: string; description: string; type: string; categories: never[]; requirement: { kibana: { versions: string; }; elasticsearch: { versions: string; }; }; ... 4 more ...; status: "not_installed"; }' is not assignable to type 'Installable<Pick<RegistryPackage | ArchivePackage, "name" | "version" | "release" | "description" | "type" | "icons" | "internal" | "data_streams" | ... 4 more ... | "format_version"> & PackageAdditions>'. Object literal may only specify known properties, and 'requirement' does not exist in type 'NotInstalled<Pick<RegistryPackage | ArchivePackage, "name" | "version" | "release" | "description" | "type" | "icons" | "internal" | "data_streams" | ... 4 more ... | "format_version"> & PackageAdditions>'.
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…83965) * update getPackgeInfo handler to fetch from install source * add tests and modify fixtures to distinguish between registry and uploaded package * improve error handling * fix type * fix test * remove try/catch * fix zip file test to have the right number of assets * fix compressed files
getPackageInfo
is the handler for the route/api/fleet/epm/packages/{pkg}
. Before this change it always reached out to the registry to get the package. For example if you uploaded a package calledapache-0.1.4
and visited/api/fleet/epm/packages/apache-0.1.4
the registry package would be returned and not the one you uploaded. This updates to check the install source, if installed, and fetch from that source.update
getPackageInfo
to look at install source before looking for the package. If an uploaded package doesn't exist in memory, it will throw an error. This will be updated once the package storage is available and it would look there next before throwing an error, probably a 404.update the .zip and .tar.gz fixtures for apache-0.1.4 package to differentiate itself from the one in the registry to make testing easier. the description in the manifest was changed and the README.md in /docs to say "Apache Uploaded Test Integration". This is compared in an integration test and you can easily see the different when navigating to the package details in the UI
introduces
getPackageFromSource
which can be updated once the package storage is available.This change is needed for #83312 and #83311
Test:
curl -X POST -u elastic:changeme http://localhost:5603/ssg/api/fleet/epm/packages --data-binary @dev/elastic/kibana/x-pack/test/fleet_api_integration/apis/fixtures/direct_upload_packages/apache_0.1.4.tar.gz -H 'kbn-xsrf: xyz' -H 'Content-Type: application/gzip'