Skip to content

Commit

Permalink
package_assets key in EPM packages SO is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Feb 17, 2021
1 parent 7fc5613 commit 2c89413
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export type PackageInfo =
export interface Installation extends SavedObjectAttributes {
installed_kibana: KibanaAssetReference[];
installed_es: EsAssetReference[];
package_assets: PackageAssetReference[];
package_assets?: PackageAssetReference[];
es_index_patterns: Record<string, string>;
name: string;
version: string;
Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/fleet/server/services/epm/packages/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants';
import { ArchivePackage, RegistryPackage, EpmPackageAdditions } from '../../../../common/types';
import { Installation, PackageInfo, KibanaAssetType } from '../../../types';
import { IngestManagerError } from '../../../errors';
import * as Registry from '../registry';
import { createInstallableFrom, isRequiredPackage } from './index';
import { getEsPackage } from '../archive/storage';
Expand Down Expand Up @@ -185,7 +186,8 @@ export async function getPackageFromSource(options: {
name: pkgName,
version: pkgVersion,
});
if (!res) {

if (!res && installedPkg.package_assets) {
res = await getEsPackage(
pkgName,
pkgVersion,
Expand All @@ -207,7 +209,9 @@ export async function getPackageFromSource(options: {
// else package is not installed or installed and missing from cache and storage and installed from registry
res = await Registry.getRegistryPackage(pkgName, pkgVersion);
}
if (!res) throw new Error(`package info for ${pkgName}-${pkgVersion} does not exist`);
if (!res) {
throw new IngestManagerError(`package info for ${pkgName}-${pkgVersion} does not exist`);
}
return {
paths: res.paths,
packageInfo: res.packageInfo,
Expand Down

0 comments on commit 2c89413

Please sign in to comment.