From 6a55d46b2e42f6b24472a37c9e85fed3da0a43a6 Mon Sep 17 00:00:00 2001 From: Sonja Krause-Harder Date: Wed, 13 Jan 2021 16:32:55 +0100 Subject: [PATCH] [EPM] Include both kibana and elasticsearch assets in package information (#88036) * Return both kibana and elasticsearch assets. * Fix type complaints. --- .../common/services/package_to_package_policy.test.ts | 8 ++++++++ x-pack/plugins/fleet/common/types/models/epm.ts | 4 ++-- .../public/applications/fleet/sections/epm/constants.tsx | 3 ++- .../plugins/fleet/server/services/epm/registry/index.ts | 7 +++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts b/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts index 36972270de01..3523c73ee64e 100644 --- a/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts +++ b/x-pack/plugins/fleet/common/services/package_to_package_policy.test.ts @@ -27,6 +27,14 @@ describe('Fleet - packageToPackagePolicy', () => { index_pattern: [], map: [], }, + elasticsearch: { + ingest_pipeline: [], + component_template: [], + index_template: [], + transform: [], + ilm_policy: [], + data_stream_ilm_policy: [], + }, }, status: 'not_installed', release: 'experimental', diff --git a/x-pack/plugins/fleet/common/types/models/epm.ts b/x-pack/plugins/fleet/common/types/models/epm.ts index 08f92f406b90..672486355741 100644 --- a/x-pack/plugins/fleet/common/types/models/epm.ts +++ b/x-pack/plugins/fleet/common/types/models/epm.ts @@ -187,8 +187,8 @@ export type AssetTypeToParts = KibanaAssetTypeToParts & ElasticsearchAssetTypeTo export type AssetsGroupedByServiceByType = Record< Extract, KibanaAssetTypeToParts ->; -// & Record, ElasticsearchAssetTypeToParts>; +> & + Record, ElasticsearchAssetTypeToParts>; export type KibanaAssetParts = AssetParts & { service: Extract; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx index 26e36621802f..533026aa93f7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/epm/constants.tsx @@ -30,8 +30,9 @@ export const AssetTitleMap: Record = { data_stream_ilm_policy: 'Data Stream ILM Policy', }; -export const ServiceTitleMap: Record, string> = { +export const ServiceTitleMap: Record = { kibana: 'Kibana', + elasticsearch: 'Elasticsearch', }; export const AssetIcons: Record = { diff --git a/x-pack/plugins/fleet/server/services/epm/registry/index.ts b/x-pack/plugins/fleet/server/services/epm/registry/index.ts index dc4f02c94acd..61bbb4cddd08 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/index.ts @@ -208,7 +208,10 @@ export function groupPathsByService(paths: string[]): AssetsGroupedByServiceByTy // ASK: best way, if any, to avoid `any`? const assets = paths.reduce((map: any, path) => { const parts = getPathParts(path.replace(/^\/package\//, '')); - if (parts.service === 'kibana' && kibanaAssetTypes.includes(parts.type)) { + if ( + (parts.service === 'kibana' && kibanaAssetTypes.includes(parts.type)) || + parts.service === 'elasticsearch' + ) { if (!map[parts.service]) map[parts.service] = {}; if (!map[parts.service][parts.type]) map[parts.service][parts.type] = []; map[parts.service][parts.type].push(parts); @@ -219,6 +222,6 @@ export function groupPathsByService(paths: string[]): AssetsGroupedByServiceByTy return { kibana: assets.kibana, - // elasticsearch: assets.elasticsearch, + elasticsearch: assets.elasticsearch, }; }