From 09d66676054bf6dd3b1984f2b2b2466a74464ccf Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Wed, 25 Mar 2020 18:43:33 -0600 Subject: [PATCH] [7.x] Fix plugin enabled config options (#60998) (#61355) * Fix plugin enabled config options (#60998) * Fix types --- src/plugins/apm_oss/server/index.ts | 1 + src/plugins/apm_oss/server/mocks.ts | 1 + src/plugins/timelion/config.ts | 1 + .../plugins/advanced_ui_actions/kibana.json | 1 + x-pack/plugins/alerting_builtins/kibana.json | 1 + x-pack/plugins/data_enhanced/kibana.json | 2 +- x-pack/plugins/drilldowns/kibana.json | 1 + x-pack/plugins/features/kibana.json | 1 + x-pack/plugins/lens/kibana.json | 3 +- x-pack/plugins/observability/kibana.json | 1 + x-pack/plugins/oss_telemetry/kibana.json | 1 + x-pack/plugins/reporting/kibana.json | 1 + x-pack/plugins/searchprofiler/kibana.json | 1 + .../plugins/triggers_actions_ui/kibana.json | 3 +- .../server/lib/apm/extract_index_patterns.ts | 36 ++++++++++++------- x-pack/plugins/uptime/kibana.json | 2 +- x-pack/plugins/watcher/kibana.json | 1 + 17 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/plugins/apm_oss/server/index.ts b/src/plugins/apm_oss/server/index.ts index 9a98a02047a2..60b16e54c98f 100644 --- a/src/plugins/apm_oss/server/index.ts +++ b/src/plugins/apm_oss/server/index.ts @@ -23,6 +23,7 @@ import { APMOSSPlugin } from './plugin'; export const config = { schema: schema.object({ + enabled: schema.boolean({ defaultValue: true }), transactionIndices: schema.string({ defaultValue: 'apm-*' }), spanIndices: schema.string({ defaultValue: 'apm-*' }), errorIndices: schema.string({ defaultValue: 'apm-*' }), diff --git a/src/plugins/apm_oss/server/mocks.ts b/src/plugins/apm_oss/server/mocks.ts index 68cb00440802..30904ab30d86 100644 --- a/src/plugins/apm_oss/server/mocks.ts +++ b/src/plugins/apm_oss/server/mocks.ts @@ -24,6 +24,7 @@ import { APMOSSPluginSetup } from './plugin'; const apmStar = 'apm-*'; const defaultConfig = { + enabled: true, errorIndices: apmStar, indexPattern: apmStar, metricsIndices: apmStar, diff --git a/src/plugins/timelion/config.ts b/src/plugins/timelion/config.ts index eaea1aaca1b7..97a423331b92 100644 --- a/src/plugins/timelion/config.ts +++ b/src/plugins/timelion/config.ts @@ -21,6 +21,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; export const configSchema = schema.object( { + enabled: schema.boolean({ defaultValue: true }), ui: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), graphiteUrls: schema.maybe(schema.arrayOf(schema.string())), }, diff --git a/x-pack/plugins/advanced_ui_actions/kibana.json b/x-pack/plugins/advanced_ui_actions/kibana.json index 515c4749de21..45907e2d8b60 100644 --- a/x-pack/plugins/advanced_ui_actions/kibana.json +++ b/x-pack/plugins/advanced_ui_actions/kibana.json @@ -1,6 +1,7 @@ { "id": "advancedUiActions", "version": "kibana", + "configPath": ["xpack", "advanced_ui_actions"], "requiredPlugins": [ "embeddable", "uiActions" diff --git a/x-pack/plugins/alerting_builtins/kibana.json b/x-pack/plugins/alerting_builtins/kibana.json index cd6bb7519c09..78de9a1ae016 100644 --- a/x-pack/plugins/alerting_builtins/kibana.json +++ b/x-pack/plugins/alerting_builtins/kibana.json @@ -4,5 +4,6 @@ "version": "8.0.0", "kibanaVersion": "kibana", "requiredPlugins": ["alerting"], + "configPath": ["xpack", "alerting_builtins"], "ui": false } diff --git a/x-pack/plugins/data_enhanced/kibana.json b/x-pack/plugins/data_enhanced/kibana.json index b2d5f42d9e46..443bb63a2779 100644 --- a/x-pack/plugins/data_enhanced/kibana.json +++ b/x-pack/plugins/data_enhanced/kibana.json @@ -3,7 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "configPath": [ - "xpack" + "xpack", "data_enhanced" ], "requiredPlugins": [ "data" diff --git a/x-pack/plugins/drilldowns/kibana.json b/x-pack/plugins/drilldowns/kibana.json index b951c7dc1fc8..4dba07b5a7be 100644 --- a/x-pack/plugins/drilldowns/kibana.json +++ b/x-pack/plugins/drilldowns/kibana.json @@ -3,6 +3,7 @@ "version": "kibana", "server": false, "ui": true, + "configPath": ["xpack", "drilldowns"], "requiredPlugins": [ "uiActions", "embeddable" diff --git a/x-pack/plugins/features/kibana.json b/x-pack/plugins/features/kibana.json index e38d7be89290..325e5a040749 100644 --- a/x-pack/plugins/features/kibana.json +++ b/x-pack/plugins/features/kibana.json @@ -3,6 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "optionalPlugins": ["timelion"], + "configPath": ["xpack", "features"], "server": true, "ui": true } diff --git a/x-pack/plugins/lens/kibana.json b/x-pack/plugins/lens/kibana.json index 867a7454f044..6abdaad7903b 100644 --- a/x-pack/plugins/lens/kibana.json +++ b/x-pack/plugins/lens/kibana.json @@ -4,5 +4,6 @@ "kibanaVersion": "kibana", "server": true, "ui": false, - "optionalPlugins": ["usageCollection", "taskManager"] + "optionalPlugins": ["usageCollection", "taskManager"], + "configPath": ["xpack", "lens"] } diff --git a/x-pack/plugins/observability/kibana.json b/x-pack/plugins/observability/kibana.json index 57063ea729ed..438b9ddea473 100644 --- a/x-pack/plugins/observability/kibana.json +++ b/x-pack/plugins/observability/kibana.json @@ -2,5 +2,6 @@ "id": "observability", "version": "8.0.0", "kibanaVersion": "kibana", + "configPath": ["xpack", "observability"], "ui": true } diff --git a/x-pack/plugins/oss_telemetry/kibana.json b/x-pack/plugins/oss_telemetry/kibana.json index d83894f7c44a..0defee0881e0 100644 --- a/x-pack/plugins/oss_telemetry/kibana.json +++ b/x-pack/plugins/oss_telemetry/kibana.json @@ -4,5 +4,6 @@ "version": "8.0.0", "kibanaVersion": "kibana", "requiredPlugins": ["usageCollection", "taskManager"], + "configPath": ["xpack", "oss_telemetry"], "ui": false } diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index a7e2bd288f0b..3da2d2a09470 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -2,6 +2,7 @@ "id": "reporting", "version": "8.0.0", "kibanaVersion": "kibana", + "configPath": ["xpack", "reporting"], "requiredPlugins": [ "home", "management", diff --git a/x-pack/plugins/searchprofiler/kibana.json b/x-pack/plugins/searchprofiler/kibana.json index 183130821240..f92083ee9d9f 100644 --- a/x-pack/plugins/searchprofiler/kibana.json +++ b/x-pack/plugins/searchprofiler/kibana.json @@ -3,6 +3,7 @@ "version": "8.0.0", "kibanaVersion": "kibana", "requiredPlugins": ["devTools", "home", "licensing"], + "configPath": ["xpack", "searchprofiler"], "server": true, "ui": true } diff --git a/x-pack/plugins/triggers_actions_ui/kibana.json b/x-pack/plugins/triggers_actions_ui/kibana.json index d11f2b3e51c9..11cbacee08af 100644 --- a/x-pack/plugins/triggers_actions_ui/kibana.json +++ b/x-pack/plugins/triggers_actions_ui/kibana.json @@ -4,5 +4,6 @@ "server": false, "ui": true, "optionalPlugins": ["alerting", "alertingBuiltins"], - "requiredPlugins": ["management", "charts", "data"] + "requiredPlugins": ["management", "charts", "data"], + "configPath": ["xpack", "trigger_actions_ui"] } diff --git a/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts b/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts index dd142dded6e7..f45ebf60f026 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/apm/extract_index_patterns.ts @@ -3,16 +3,28 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { uniq } from 'lodash'; +import { uniq, pick } from 'lodash'; +import { APMOSSConfig } from '../../../../../../src/plugins/apm_oss/server'; -export const extractIndexPatterns = (apmConfig: Record): string[] => - uniq( - [ - 'sourcemapIndices', - 'errorIndices', - 'transactionIndices', - 'spanIndices', - 'metricsIndices', - 'onboardingIndices', - ].map(type => apmConfig[type]!) - ); +type APMIndexConfig = Pick< + APMOSSConfig, + | 'sourcemapIndices' + | 'errorIndices' + | 'transactionIndices' + | 'spanIndices' + | 'metricsIndices' + | 'onboardingIndices' +>; + +export const extractIndexPatterns = (apmConfig: APMOSSConfig): string[] => { + const indexConfigs = pick(apmConfig, [ + 'sourcemapIndices', + 'errorIndices', + 'transactionIndices', + 'spanIndices', + 'metricsIndices', + 'onboardingIndices', + ]); + + return uniq(Object.values(indexConfigs)); +}; diff --git a/x-pack/plugins/uptime/kibana.json b/x-pack/plugins/uptime/kibana.json index 603cfac316b2..6ec8a755ebea 100644 --- a/x-pack/plugins/uptime/kibana.json +++ b/x-pack/plugins/uptime/kibana.json @@ -1,5 +1,5 @@ { - "configPath": ["xpack"], + "configPath": ["xpack", "uptime"], "id": "uptime", "kibanaVersion": "kibana", "requiredPlugins": ["alerting", "features", "licensing", "usageCollection"], diff --git a/x-pack/plugins/watcher/kibana.json b/x-pack/plugins/watcher/kibana.json index 7c02118c58d7..a0482ad00797 100644 --- a/x-pack/plugins/watcher/kibana.json +++ b/x-pack/plugins/watcher/kibana.json @@ -1,5 +1,6 @@ { "id": "watcher", + "configPath": ["xpack", "watcher"], "version": "kibana", "requiredPlugins": [ "home",