Skip to content

Commit

Permalink
[Fleet] added support for installing tag saved objects (elastic#114110)
Browse files Browse the repository at this point in the history
* added tag saved objects to assets

* fixed review comments

* added translation to constants

* added missing icon type

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
juliaElastic and kibanamachine committed Oct 11, 2021
1 parent 7f83f29 commit 66fece9
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('Fleet - packageToPackagePolicy', () => {
lens: [],
ml_module: [],
security_rule: [],
tag: [],
},
elasticsearch: {
ingest_pipeline: [],
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export enum KibanaAssetType {
lens = 'lens',
securityRule = 'security_rule',
mlModule = 'ml_module',
tag = 'tag',
}

/*
Expand All @@ -83,6 +84,7 @@ export enum KibanaSavedObjectType {
lens = 'lens',
mlModule = 'ml-module',
securityRule = 'security-rule',
tag = 'tag',
}

export enum ElasticsearchAssetType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const AssetsFacetGroup = ({ width }: Args) => {
lens: [],
security_rule: [],
ml_module: [],
tag: [],
},
elasticsearch: {
component_template: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import type { IconType } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import type { ServiceName } from '../../types';
import { ElasticsearchAssetType, KibanaAssetType } from '../../types';
Expand All @@ -22,21 +23,54 @@ export const DisplayedAssets: ServiceNameToAssetTypes = {
export type DisplayedAssetType = ElasticsearchAssetType | KibanaAssetType | 'view';

export const AssetTitleMap: Record<DisplayedAssetType, string> = {
dashboard: 'Dashboards',
ilm_policy: 'ILM policies',
ingest_pipeline: 'Ingest pipelines',
transform: 'Transforms',
index_pattern: 'Index patterns',
index_template: 'Index templates',
component_template: 'Component templates',
search: 'Saved searches',
visualization: 'Visualizations',
map: 'Maps',
data_stream_ilm_policy: 'Data stream ILM policies',
lens: 'Lens',
security_rule: 'Security rules',
ml_module: 'ML modules',
view: 'Views',
dashboard: i18n.translate('xpack.fleet.epm.assetTitles.dashboards', {
defaultMessage: 'Dashboards',
}),
ilm_policy: i18n.translate('xpack.fleet.epm.assetTitles.ilmPolicies', {
defaultMessage: 'ILM policies',
}),
ingest_pipeline: i18n.translate('xpack.fleet.epm.assetTitles.ingestPipelines', {
defaultMessage: 'Ingest pipelines',
}),
transform: i18n.translate('xpack.fleet.epm.assetTitles.transforms', {
defaultMessage: 'Transforms',
}),
index_pattern: i18n.translate('xpack.fleet.epm.assetTitles.indexPatterns', {
defaultMessage: 'Index patterns',
}),
index_template: i18n.translate('xpack.fleet.epm.assetTitles.indexTemplates', {
defaultMessage: 'Index templates',
}),
component_template: i18n.translate('xpack.fleet.epm.assetTitles.componentTemplates', {
defaultMessage: 'Component templates',
}),
search: i18n.translate('xpack.fleet.epm.assetTitles.savedSearches', {
defaultMessage: 'Saved searches',
}),
visualization: i18n.translate('xpack.fleet.epm.assetTitles.visualizations', {
defaultMessage: 'Visualizations',
}),
map: i18n.translate('xpack.fleet.epm.assetTitles.maps', {
defaultMessage: 'Maps',
}),
data_stream_ilm_policy: i18n.translate('xpack.fleet.epm.assetTitles.dataStreamILM', {
defaultMessage: 'Data stream ILM policies',
}),
lens: i18n.translate('xpack.fleet.epm.assetTitles.lens', {
defaultMessage: 'Lens',
}),
security_rule: i18n.translate('xpack.fleet.epm.assetTitles.securityRules', {
defaultMessage: 'Security rules',
}),
ml_module: i18n.translate('xpack.fleet.epm.assetTitles.mlModules', {
defaultMessage: 'ML modules',
}),
view: i18n.translate('xpack.fleet.epm.assetTitles.views', {
defaultMessage: 'Views',
}),
tag: i18n.translate('xpack.fleet.epm.assetTitles.tag', {
defaultMessage: 'Tag',
}),
};

export const ServiceTitleMap: Record<ServiceName, string> = {
Expand All @@ -53,6 +87,7 @@ export const AssetIcons: Record<KibanaAssetType, IconType> = {
lens: 'lensApp',
security_rule: 'securityApp',
ml_module: 'mlApp',
tag: 'tagApp',
};

export const ServiceIcons: Record<ServiceName, IconType> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const KibanaSavedObjectTypeMapping: Record<KibanaAssetType, KibanaSavedObjectTyp
[KibanaAssetType.lens]: KibanaSavedObjectType.lens,
[KibanaAssetType.mlModule]: KibanaSavedObjectType.mlModule,
[KibanaAssetType.securityRule]: KibanaSavedObjectType.securityRule,
[KibanaAssetType.tag]: KibanaSavedObjectType.tag,
};

// Define how each asset type will be installed
Expand All @@ -57,6 +58,7 @@ const AssetInstallers: Record<
[KibanaAssetType.lens]: installKibanaSavedObjects,
[KibanaAssetType.mlModule]: installKibanaSavedObjects,
[KibanaAssetType.securityRule]: installKibanaSavedObjects,
[KibanaAssetType.tag]: installKibanaSavedObjects,
};

export async function getKibanaAsset(key: string): Promise<ArchiveAsset> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('storedPackagePoliciesToAgentPermissions()', () => {
lens: [],
security_rule: [],
ml_module: [],
tag: [],
},
elasticsearch: {
component_template: [],
Expand Down Expand Up @@ -207,6 +208,7 @@ describe('storedPackagePoliciesToAgentPermissions()', () => {
lens: [],
security_rule: [],
ml_module: [],
tag: [],
},
elasticsearch: {
component_template: [],
Expand Down Expand Up @@ -323,6 +325,7 @@ describe('storedPackagePoliciesToAgentPermissions()', () => {
lens: [],
security_rule: [],
ml_module: [],
tag: [],
},
elasticsearch: {
component_template: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export const response: GetInfoResponse['response'] = {
lens: [],
map: [],
security_rule: [],
tag: [],
},
elasticsearch: {
ingest_pipeline: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const response: GetInfoResponse['response'] = {
lens: [],
ml_module: [],
security_rule: [],
tag: [],
},
elasticsearch: {
ingest_pipeline: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ const expectAssetsInstalled = ({
id: 'sample_dashboard',
});
expect(resDashboard.id).equal('sample_dashboard');
expect(resDashboard.references.map((ref: any) => ref.id).includes('sample_tag')).equal(true);
const resDashboard2 = await kibanaServer.savedObjects.get({
type: 'dashboard',
id: 'sample_dashboard2',
Expand Down Expand Up @@ -444,6 +445,11 @@ const expectAssetsInstalled = ({
id: 'sample_security_rule',
});
expect(resSecurityRule.id).equal('sample_security_rule');
const resTag = await kibanaServer.savedObjects.get({
type: 'tag',
id: 'sample_tag',
});
expect(resTag.id).equal('sample_tag');
const resIndexPattern = await kibanaServer.savedObjects.get({
type: 'index-pattern',
id: 'test-*',
Expand Down Expand Up @@ -521,6 +527,10 @@ const expectAssetsInstalled = ({
id: 'sample_security_rule',
type: 'security-rule',
},
{
id: 'sample_tag',
type: 'tag',
},
{
id: 'sample_visualization',
type: 'visualization',
Expand Down Expand Up @@ -607,6 +617,7 @@ const expectAssetsInstalled = ({
{ id: '4c758d70-ecf1-56b3-b704-6d8374841b34', type: 'epm-packages-assets' },
{ id: 'e786cbd9-0f3b-5a0b-82a6-db25145ebf58', type: 'epm-packages-assets' },
{ id: 'd8b175c3-0d42-5ec7-90c1-d1e4b307a4c2', type: 'epm-packages-assets' },
{ id: 'b265a5e0-c00b-5eda-ac44-2ddbd36d9ad0', type: 'epm-packages-assets' },
{ id: '53c94591-aa33-591d-8200-cd524c2a0561', type: 'epm-packages-assets' },
{ id: 'b658d2d4-752e-54b8-afc2-4c76155c1466', type: 'epm-packages-assets' },
],
Expand Down
5 changes: 5 additions & 0 deletions x-pack/test/fleet_api_integration/apis/epm/update_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ export default function (providerContext: FtrProviderContext) {
id: 'sample_ml_module',
type: 'ml-module',
},
{
id: 'sample_tag',
type: 'tag',
},
],
installed_es: [
{
Expand Down Expand Up @@ -418,6 +422,7 @@ export default function (providerContext: FtrProviderContext) {
{ id: '4281a436-45a8-54ab-9724-fda6849f789d', type: 'epm-packages-assets' },
{ id: '2e56f08b-1d06-55ed-abee-4708e1ccf0aa', type: 'epm-packages-assets' },
{ id: '4035007b-9c33-5227-9803-2de8a17523b5', type: 'epm-packages-assets' },
{ id: 'e6ae7d31-6920-5408-9219-91ef1662044b', type: 'epm-packages-assets' },
{ id: 'c7bf1a39-e057-58a0-afde-fb4b48751d8c', type: 'epm-packages-assets' },
{ id: '8c665f28-a439-5f43-b5fd-8fda7b576735', type: 'epm-packages-assets' },
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
{ "id": "sample_visualization", "name": "panel_0", "type": "visualization" },
{ "id": "sample_search", "name": "panel_1", "type": "search" },
{ "id": "sample_search", "name": "panel_2", "type": "search" },
{ "id": "sample_visualization", "name": "panel_3", "type": "visualization" }
{ "id": "sample_visualization", "name": "panel_3", "type": "visualization" },
{ "id": "sample_tag", "type": "tag", "name": "tag-ref-sample_tag" }
],
"id": "sample_dashboard",
"type": "dashboard"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "sample_tag",
"type": "tag",
"namespaces": [
"default"
],
"attributes": {
"name": "my tag",
"description": "",
"color": "#a80853"
},
"references": [],
"migrationVersion": {
"tag": "8.0.0"
},
"coreMigrationVersion": "8.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
{ "id": "sample_visualization", "name": "panel_0", "type": "visualization" },
{ "id": "sample_search2", "name": "panel_1", "type": "search" },
{ "id": "sample_search2", "name": "panel_2", "type": "search" },
{ "id": "sample_visualization", "name": "panel_3", "type": "visualization" }
{ "id": "sample_visualization", "name": "panel_3", "type": "visualization" },
{ "id": "sample_tag", "type": "tag", "name": "tag-ref-sample_tag" }
],
"id": "sample_dashboard",
"type": "dashboard"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "sample_tag",
"type": "tag",
"namespaces": [
"default"
],
"attributes": {
"name": "my tag",
"description": "",
"color": "#a80853"
},
"references": [],
"migrationVersion": {
"tag": "8.0.0"
},
"coreMigrationVersion": "8.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ requirement:
icons:
- src: '/img/logo_overrides_64_color.svg'
size: '16x16'
type: 'image/svg+xml'

0 comments on commit 66fece9

Please sign in to comment.