Skip to content
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
1 change: 1 addition & 0 deletions x-pack/plugins/ingest_manager/server/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const savedObjectMappings = {
properties: {
name: { type: 'keyword' },
version: { type: 'keyword' },
internal: { type: 'boolean' },
installed: {
type: 'nested',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ export async function getPackages(
Object.assign({}, item, { title: item.title || nameAsTitle(item.name) })
);
});
const searchObjects = registryItems.map(({ name, version }) => ({
// get the installed packages
const results = await savedObjectsClient.find<Installation>({
type: PACKAGES_SAVED_OBJECT_TYPE,
id: `${name}-${version}`,
}));
const results = await savedObjectsClient.bulkGet<Installation>(searchObjects);
const savedObjects = results.saved_objects.filter(o => !o.error); // ignore errors for now
});
// filter out any internal packages
const savedObjectsVisible = results.saved_objects.filter(o => !o.attributes.internal);
const packageList = registryItems
.map(item =>
createInstallableFrom(
item,
savedObjects.find(({ id }) => id === `${item.name}-${item.version}`)
savedObjectsVisible.find(({ attributes }) => attributes.name === item.name)
)
)
.sort(sortByName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function installPackage(options: {
}): Promise<AssetReference[]> {
const { savedObjectsClient, pkgkey, callCluster } = options;
const registryPackageInfo = await Registry.fetchInfo(pkgkey);
const { name: pkgName, version: pkgVersion } = registryPackageInfo;
const { name: pkgName, version: pkgVersion, internal = false } = registryPackageInfo;

const installKibanaAssetsPromise = installKibanaAssets({
savedObjectsClient,
Expand Down Expand Up @@ -116,6 +116,7 @@ export async function installPackage(options: {
pkgkey,
pkgName,
pkgVersion,
internal,
toSave,
});
return toSave;
Expand Down Expand Up @@ -145,9 +146,10 @@ export async function saveInstallationReferences(options: {
pkgkey: string;
pkgName: string;
pkgVersion: string;
internal: boolean;
toSave: AssetReference[];
}) {
const { savedObjectsClient, pkgkey, pkgName, pkgVersion, toSave } = options;
const { savedObjectsClient, pkgkey, pkgName, pkgVersion, internal, toSave } = options;
const installation = await getInstallation({ savedObjectsClient, pkgkey });
const savedRefs = installation?.installed || [];
const mergeRefsReducer = (current: AssetReference[], pending: AssetReference) => {
Expand All @@ -159,7 +161,7 @@ export async function saveInstallationReferences(options: {
const toInstall = toSave.reduce(mergeRefsReducer, savedRefs);
await savedObjectsClient.create<Installation>(
PACKAGES_SAVED_OBJECT_TYPE,
{ installed: toInstall, name: pkgName, version: pkgVersion },
{ installed: toInstall, name: pkgName, version: pkgVersion, internal },
{ id: pkgkey, overwrite: true }
);

Expand Down