;
+}
+
// @public
export type RequestHandler = (context: Context, request: KibanaRequest
, response: ResponseFactory) => IKibanaResponse | Promise>;
diff --git a/src/core/server/server.ts b/src/core/server/server.ts
index 8905bcd28fe17..b575b2779082c 100644
--- a/src/core/server/server.ts
+++ b/src/core/server/server.ts
@@ -41,6 +41,7 @@ import { ContextService } from './context';
import { RequestHandlerContext } from '.';
import { InternalCoreSetup, InternalCoreStart, ServiceConfigDescriptor } from './internal_types';
import { CoreUsageDataService } from './core_usage_data';
+import { DeprecationsService } from './deprecations';
import { CoreRouteHandlerContext } from './core_route_handler_context';
import { config as externalUrlConfig } from './external_url';
@@ -67,6 +68,7 @@ export class Server {
private readonly coreApp: CoreApp;
private readonly coreUsageData: CoreUsageDataService;
private readonly i18n: I18nService;
+ private readonly deprecations: DeprecationsService;
private readonly savedObjectsStartPromise: Promise;
private resolveSavedObjectsStartPromise?: (value: SavedObjectsServiceStart) => void;
@@ -102,6 +104,7 @@ export class Server {
this.logging = new LoggingService(core);
this.coreUsageData = new CoreUsageDataService(core);
this.i18n = new I18nService(core);
+ this.deprecations = new DeprecationsService(core);
this.savedObjectsStartPromise = new Promise((resolve) => {
this.resolveSavedObjectsStartPromise = resolve;
@@ -192,6 +195,12 @@ export class Server {
loggingSystem: this.loggingSystem,
});
+ const deprecationsSetup = this.deprecations.setup({
+ http: httpSetup,
+ elasticsearch: elasticsearchServiceSetup,
+ coreUsageData: coreUsageDataSetup,
+ });
+
const coreSetup: InternalCoreSetup = {
capabilities: capabilitiesSetup,
context: contextServiceSetup,
@@ -206,6 +215,7 @@ export class Server {
httpResources: httpResourcesSetup,
logging: loggingSetup,
metrics: metricsSetup,
+ deprecations: deprecationsSetup,
};
const pluginsSetup = await this.plugins.setup(coreSetup);
@@ -285,6 +295,7 @@ export class Server {
await this.metrics.stop();
await this.status.stop();
await this.logging.stop();
+ this.deprecations.stop();
}
private registerCoreContext(coreSetup: InternalCoreSetup) {
diff --git a/src/core/server/types.ts b/src/core/server/types.ts
index 6bd805d55af1d..ab1d6c6d95d0a 100644
--- a/src/core/server/types.ts
+++ b/src/core/server/types.ts
@@ -37,6 +37,7 @@ export type {
SavedObjectsClientContract,
SavedObjectsNamespaceType,
} from './saved_objects/types';
+export type { DomainDeprecationDetails, DeprecationsGetResponse } from './deprecations/types';
export * from './ui_settings/types';
export * from './legacy/types';
export type { EnvironmentMode, PackageInfo } from '@kbn/config';
diff --git a/src/plugins/kibana_legacy/server/index.ts b/src/plugins/kibana_legacy/server/index.ts
index 15511e1e9f7f2..1402416d69c96 100644
--- a/src/plugins/kibana_legacy/server/index.ts
+++ b/src/plugins/kibana_legacy/server/index.ts
@@ -6,12 +6,7 @@
* Side Public License, v 1.
*/
-import {
- ConfigDeprecationLogger,
- CoreSetup,
- CoreStart,
- PluginConfigDescriptor,
-} from 'kibana/server';
+import { AddConfigDeprecation, CoreSetup, CoreStart, PluginConfigDescriptor } from 'kibana/server';
import { get } from 'lodash';
import { configSchema, ConfigSchema } from '../config';
@@ -23,17 +18,28 @@ export const config: PluginConfigDescriptor = {
schema: configSchema,
deprecations: ({ renameFromRoot }) => [
// TODO: Remove deprecation once defaultAppId is deleted
- renameFromRoot('kibana.defaultAppId', 'kibana_legacy.defaultAppId', true),
- (completeConfig: Record, rootPath: string, log: ConfigDeprecationLogger) => {
+ renameFromRoot('kibana.defaultAppId', 'kibana_legacy.defaultAppId', { silent: true }),
+ (
+ completeConfig: Record,
+ rootPath: string,
+ addDeprecation: AddConfigDeprecation
+ ) => {
if (
get(completeConfig, 'kibana.defaultAppId') === undefined &&
get(completeConfig, 'kibana_legacy.defaultAppId') === undefined
) {
return completeConfig;
}
- log(
- `kibana.defaultAppId is deprecated and will be removed in 8.0. Please use the \`defaultRoute\` advanced setting instead`
- );
+ addDeprecation({
+ message: `kibana.defaultAppId is deprecated and will be removed in 8.0. Please use the \`defaultRoute\` advanced setting instead`,
+ correctiveActions: {
+ manualSteps: [
+ 'Go to Stack Management > Advanced Settings',
+ 'Update the "defaultRoute" setting under the General section',
+ 'Remove "kibana.defaultAppId" from the kibana.yml config file',
+ ],
+ },
+ });
return completeConfig;
},
],
diff --git a/src/plugins/timelion/server/deprecations.ts b/src/plugins/timelion/server/deprecations.ts
new file mode 100644
index 0000000000000..3d4e687f154cf
--- /dev/null
+++ b/src/plugins/timelion/server/deprecations.ts
@@ -0,0 +1,70 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import {
+ CoreStart,
+ SavedObjectsClient,
+ Logger,
+ GetDeprecationsContext,
+ DeprecationsDetails,
+} from 'src/core/server';
+
+export const getTimelionSheetsCount = async (
+ savedObjectsClient: Pick
+) => {
+ const { total } = await savedObjectsClient.find({ type: 'timelion-sheet', perPage: 1 });
+ return total;
+};
+
+export const showWarningMessageIfTimelionSheetWasFound = async (
+ core: CoreStart,
+ logger: Logger
+) => {
+ const { savedObjects } = core;
+ const savedObjectsClient = savedObjects.createInternalRepository();
+ const count = await getTimelionSheetsCount(savedObjectsClient);
+ if (count > 0) {
+ logger.warn(
+ 'Deprecated since 7.0, the Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard. See https://www.elastic.co/guide/en/kibana/current/create-panels-with-timelion.html.'
+ );
+ }
+};
+
+/**
+ * Deprecated since 7.0, the Timelion app will be removed in 8.0.
+ * To continue using your Timelion worksheets, migrate them to a dashboard.
+ *
+ * @link https://www.elastic.co/guide/en/kibana/master/timelion.html#timelion-deprecation
+ **/
+export async function getDeprecations({
+ savedObjectsClient,
+}: GetDeprecationsContext): Promise {
+ const deprecations: DeprecationsDetails[] = [];
+ const count = await getTimelionSheetsCount(savedObjectsClient);
+
+ if (count > 0) {
+ deprecations.push({
+ message: `You have ${count} Timelion worksheets. The Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard.`,
+ documentationUrl:
+ 'https://www.elastic.co/guide/en/kibana/current/create-panels-with-timelion.html',
+ level: 'warning',
+ correctiveActions: {
+ manualSteps: [
+ 'Navigate to the Kibana Dashboard and click "Create dashboard".',
+ 'Select Timelion from the "New Visualization" window.',
+ 'Open a new tab, open the Timelion app, select the chart you want to copy, then copy the chart expression.',
+ 'Go to Timelion, paste the chart expression in the Timelion expression field, then click Update.',
+ 'In the toolbar, click Save.',
+ 'On the Save visualization window, enter the visualization Title, then click Save and return.',
+ ],
+ },
+ });
+ }
+
+ return deprecations;
+}
diff --git a/src/plugins/timelion/server/plugin.ts b/src/plugins/timelion/server/plugin.ts
index 226a978fe5d88..edbba9b565ae4 100644
--- a/src/plugins/timelion/server/plugin.ts
+++ b/src/plugins/timelion/server/plugin.ts
@@ -11,30 +11,7 @@ import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { TimelionConfigType } from './config';
import { timelionSheetSavedObjectType } from './saved_objects';
-
-/**
- * Deprecated since 7.0, the Timelion app will be removed in 8.0.
- * To continue using your Timelion worksheets, migrate them to a dashboard.
- *
- * @link https://www.elastic.co/guide/en/kibana/master/timelion.html#timelion-deprecation
- **/
-const showWarningMessageIfTimelionSheetWasFound = (core: CoreStart, logger: Logger) => {
- const { savedObjects } = core;
- const savedObjectsClient = savedObjects.createInternalRepository();
-
- savedObjectsClient
- .find({
- type: 'timelion-sheet',
- perPage: 1,
- })
- .then(
- ({ total }) =>
- total &&
- logger.warn(
- 'Deprecated since 7.0, the Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard. See https://www.elastic.co/guide/en/kibana/current/create-panels-with-timelion.html.'
- )
- );
-};
+import { getDeprecations, showWarningMessageIfTimelionSheetWasFound } from './deprecations';
export class TimelionPlugin implements Plugin {
private logger: Logger;
@@ -87,6 +64,8 @@ export class TimelionPlugin implements Plugin {
schema: schema.number(),
},
});
+
+ core.deprecations.registerDeprecations({ getDeprecations });
}
start(core: CoreStart) {
showWarningMessageIfTimelionSheetWasFound(core, this.logger);
diff --git a/src/plugins/vis_type_timelion/server/index.ts b/src/plugins/vis_type_timelion/server/index.ts
index 1dcb7263c4818..35f4182a50a86 100644
--- a/src/plugins/vis_type_timelion/server/index.ts
+++ b/src/plugins/vis_type_timelion/server/index.ts
@@ -21,7 +21,7 @@ export const config: PluginConfigDescriptor = {
renameFromRoot('timelion_vis.enabled', 'vis_type_timelion.enabled'),
renameFromRoot('timelion.enabled', 'vis_type_timelion.enabled'),
renameFromRoot('timelion.graphiteUrls', 'vis_type_timelion.graphiteUrls'),
- renameFromRoot('timelion.ui.enabled', 'vis_type_timelion.ui.enabled', true),
+ renameFromRoot('timelion.ui.enabled', 'vis_type_timelion.ui.enabled', { silent: true }),
],
};
export const plugin = (initializerContext: PluginInitializerContext) =>
diff --git a/src/plugins/vis_type_timeseries/server/index.ts b/src/plugins/vis_type_timeseries/server/index.ts
index 37eda1b1338d4..3c27713c37500 100644
--- a/src/plugins/vis_type_timeseries/server/index.ts
+++ b/src/plugins/vis_type_timeseries/server/index.ts
@@ -15,9 +15,13 @@ export { VisTypeTimeseriesSetup } from './plugin';
export const config: PluginConfigDescriptor = {
deprecations: ({ unused, renameFromRoot }) => [
// In Kibana v7.8 plugin id was renamed from 'metrics' to 'vis_type_timeseries':
- renameFromRoot('metrics.enabled', 'vis_type_timeseries.enabled', true),
- renameFromRoot('metrics.chartResolution', 'vis_type_timeseries.chartResolution', true),
- renameFromRoot('metrics.minimumBucketSize', 'vis_type_timeseries.minimumBucketSize', true),
+ renameFromRoot('metrics.enabled', 'vis_type_timeseries.enabled', { silent: true }),
+ renameFromRoot('metrics.chartResolution', 'vis_type_timeseries.chartResolution', {
+ silent: true,
+ }),
+ renameFromRoot('metrics.minimumBucketSize', 'vis_type_timeseries.minimumBucketSize', {
+ silent: true,
+ }),
// Unused properties which should be removed after releasing Kibana v8.0:
unused('chartResolution'),
diff --git a/test/functional/fixtures/es_archiver/deprecations_service/data.json b/test/functional/fixtures/es_archiver/deprecations_service/data.json
new file mode 100644
index 0000000000000..31ce5af20b46c
--- /dev/null
+++ b/test/functional/fixtures/es_archiver/deprecations_service/data.json
@@ -0,0 +1,14 @@
+{
+ "type": "doc",
+ "value": {
+ "index": ".kibana",
+ "id": "test-deprecations-plugin:ff3733a0-9fty-11e7-ahb3-3dcb94193fab",
+ "source": {
+ "type": "test-deprecations-plugin",
+ "updated_at": "2021-02-11T18:51:23.794Z",
+ "test-deprecations-plugin": {
+ "title": "Test saved object"
+ }
+ }
+ }
+}
diff --git a/test/functional/fixtures/es_archiver/deprecations_service/mappings.json b/test/functional/fixtures/es_archiver/deprecations_service/mappings.json
new file mode 100644
index 0000000000000..5f7c7e0e7b7dc
--- /dev/null
+++ b/test/functional/fixtures/es_archiver/deprecations_service/mappings.json
@@ -0,0 +1,289 @@
+{
+ "type": "index",
+ "value": {
+ "index": ".kibana",
+ "mappings": {
+ "properties": {
+ "config": {
+ "dynamic": "true",
+ "properties": {
+ "buildNum": {
+ "type": "keyword"
+ },
+ "dateFormat:tz": {
+ "fields": {
+ "keyword": {
+ "ignore_above": 256,
+ "type": "keyword"
+ }
+ },
+ "type": "text"
+ }
+ }
+ },
+ "dashboard": {
+ "dynamic": "strict",
+ "properties": {
+ "description": {
+ "type": "text"
+ },
+ "hits": {
+ "type": "integer"
+ },
+ "kibanaSavedObjectMeta": {
+ "properties": {
+ "searchSourceJSON": {
+ "type": "text"
+ }
+ }
+ },
+ "optionsJSON": {
+ "type": "text"
+ },
+ "panelsJSON": {
+ "type": "text"
+ },
+ "refreshInterval": {
+ "properties": {
+ "display": {
+ "type": "keyword"
+ },
+ "pause": {
+ "type": "boolean"
+ },
+ "section": {
+ "type": "integer"
+ },
+ "value": {
+ "type": "integer"
+ }
+ }
+ },
+ "timeFrom": {
+ "type": "keyword"
+ },
+ "timeRestore": {
+ "type": "boolean"
+ },
+ "timeTo": {
+ "type": "keyword"
+ },
+ "title": {
+ "type": "text"
+ },
+ "uiStateJSON": {
+ "type": "text"
+ },
+ "version": {
+ "type": "integer"
+ }
+ }
+ },
+ "index-pattern": {
+ "dynamic": "strict",
+ "properties": {
+ "fieldFormatMap": {
+ "type": "text"
+ },
+ "fields": {
+ "type": "text"
+ },
+ "intervalName": {
+ "type": "keyword"
+ },
+ "notExpandable": {
+ "type": "boolean"
+ },
+ "sourceFilters": {
+ "type": "text"
+ },
+ "timeFieldName": {
+ "type": "keyword"
+ },
+ "title": {
+ "type": "text"
+ }
+ }
+ },
+ "search": {
+ "dynamic": "strict",
+ "properties": {
+ "columns": {
+ "type": "keyword"
+ },
+ "description": {
+ "type": "text"
+ },
+ "hits": {
+ "type": "integer"
+ },
+ "kibanaSavedObjectMeta": {
+ "properties": {
+ "searchSourceJSON": {
+ "type": "text"
+ }
+ }
+ },
+ "sort": {
+ "type": "keyword"
+ },
+ "title": {
+ "type": "text"
+ },
+ "version": {
+ "type": "integer"
+ }
+ }
+ },
+ "server": {
+ "dynamic": "strict",
+ "properties": {
+ "uuid": {
+ "type": "keyword"
+ }
+ }
+ },
+ "timelion-sheet": {
+ "dynamic": "strict",
+ "properties": {
+ "description": {
+ "type": "text"
+ },
+ "hits": {
+ "type": "integer"
+ },
+ "kibanaSavedObjectMeta": {
+ "properties": {
+ "searchSourceJSON": {
+ "type": "text"
+ }
+ }
+ },
+ "timelion_chart_height": {
+ "type": "integer"
+ },
+ "timelion_columns": {
+ "type": "integer"
+ },
+ "timelion_interval": {
+ "type": "keyword"
+ },
+ "timelion_other_interval": {
+ "type": "keyword"
+ },
+ "timelion_rows": {
+ "type": "integer"
+ },
+ "timelion_sheet": {
+ "type": "text"
+ },
+ "title": {
+ "type": "text"
+ },
+ "version": {
+ "type": "integer"
+ }
+ }
+ },
+ "type": {
+ "type": "keyword"
+ },
+ "url": {
+ "dynamic": "strict",
+ "properties": {
+ "accessCount": {
+ "type": "long"
+ },
+ "accessDate": {
+ "type": "date"
+ },
+ "createDate": {
+ "type": "date"
+ },
+ "url": {
+ "fields": {
+ "keyword": {
+ "ignore_above": 2048,
+ "type": "keyword"
+ }
+ },
+ "type": "text"
+ }
+ }
+ },
+ "visualization": {
+ "dynamic": "strict",
+ "properties": {
+ "description": {
+ "type": "text"
+ },
+ "kibanaSavedObjectMeta": {
+ "properties": {
+ "searchSourceJSON": {
+ "type": "text"
+ }
+ }
+ },
+ "savedSearchId": {
+ "type": "keyword"
+ },
+ "title": {
+ "type": "text"
+ },
+ "uiStateJSON": {
+ "type": "text"
+ },
+ "version": {
+ "type": "integer"
+ },
+ "visState": {
+ "type": "text"
+ }
+ }
+ },
+ "query": {
+ "properties": {
+ "title": {
+ "type": "text"
+ },
+ "description": {
+ "type": "text"
+ },
+ "query": {
+ "properties": {
+ "language": {
+ "type": "keyword"
+ },
+ "query": {
+ "type": "keyword",
+ "index": false
+ }
+ }
+ },
+ "filters": {
+ "type": "object",
+ "enabled": false
+ },
+ "timefilter": {
+ "type": "object",
+ "enabled": false
+ }
+ }
+ },
+ "test-deprecations-plugin": {
+ "properties": {
+ "title": {
+ "type": "text"
+ }
+ }
+ }
+ }
+ },
+ "settings": {
+ "index": {
+ "number_of_replicas": "0",
+ "number_of_shards": "1"
+ }
+ }
+ }
+}
diff --git a/test/plugin_functional/config.ts b/test/plugin_functional/config.ts
index fc747fcd71f17..1651e213ee82d 100644
--- a/test/plugin_functional/config.ts
+++ b/test/plugin_functional/config.ts
@@ -56,6 +56,9 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
// Required to load new platform plugins via `--plugin-path` flag.
'--env.name=development',
+ '--corePluginDeprecations.oldProperty=hello',
+ '--corePluginDeprecations.secret=100',
+ '--corePluginDeprecations.noLongerUsed=still_using',
...plugins.map(
(pluginDir) => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`
),
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/kibana.json b/test/plugin_functional/plugins/core_plugin_deprecations/kibana.json
new file mode 100644
index 0000000000000..bc251f97bea58
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/kibana.json
@@ -0,0 +1,8 @@
+{
+ "id": "corePluginDeprecations",
+ "version": "0.0.1",
+ "kibanaVersion": "kibana",
+ "configPath": ["corePluginDeprecations"],
+ "server": true,
+ "ui": false
+}
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/package.json b/test/plugin_functional/plugins/core_plugin_deprecations/package.json
new file mode 100644
index 0000000000000..f14ec933f59b2
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "core_plugin_deprecations",
+ "version": "1.0.0",
+ "main": "target/test/plugin_functional/plugins/core_plugin_deprecations",
+ "kibana": {
+ "version": "kibana",
+ "templateVersion": "1.0.0"
+ },
+ "license": "SSPL-1.0 OR Elastic License 2.0",
+ "scripts": {
+ "kbn": "node ../../../../scripts/kbn.js",
+ "build": "rm -rf './target' && ../../../../node_modules/.bin/tsc"
+ }
+}
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/public/application.tsx b/test/plugin_functional/plugins/core_plugin_deprecations/public/application.tsx
new file mode 100644
index 0000000000000..e2166a249e34b
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/public/application.tsx
@@ -0,0 +1,19 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import React from 'react';
+import ReactDOM from 'react-dom';
+import { AppMountParameters } from 'kibana/public';
+
+const DeprecationsApp = () => Deprcations App
;
+
+export const renderApp = ({ element }: AppMountParameters) => {
+ ReactDOM.render(, element);
+
+ return () => ReactDOM.unmountComponentAtNode(element);
+};
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/public/index.ts b/test/plugin_functional/plugins/core_plugin_deprecations/public/index.ts
new file mode 100644
index 0000000000000..bb6b3f0740b3b
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/public/index.ts
@@ -0,0 +1,19 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { PluginInitializer, PluginInitializerContext } from 'kibana/public';
+import {
+ CorePluginDeprecationsPlugin,
+ CorePluginDeprecationsPluginSetup,
+ CorePluginDeprecationsPluginStart,
+} from './plugin';
+
+export const plugin: PluginInitializer<
+ CorePluginDeprecationsPluginSetup,
+ CorePluginDeprecationsPluginStart
+> = (context: PluginInitializerContext) => new CorePluginDeprecationsPlugin(context);
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/public/plugin.tsx b/test/plugin_functional/plugins/core_plugin_deprecations/public/plugin.tsx
new file mode 100644
index 0000000000000..bf807145e14bf
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/public/plugin.tsx
@@ -0,0 +1,40 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { CoreSetup, Plugin, PluginInitializerContext } from 'kibana/public';
+
+declare global {
+ interface Window {
+ env?: PluginInitializerContext['env'];
+ }
+}
+
+export class CorePluginDeprecationsPlugin
+ implements Plugin {
+ constructor(pluginContext: PluginInitializerContext) {
+ window.env = pluginContext.env;
+ }
+ public setup(core: CoreSetup) {
+ core.application.register({
+ id: 'core-plugin-deprecations',
+ title: 'Core Plugin Deprecations',
+ async mount(params) {
+ const { renderApp } = await import('./application');
+ await core.getStartServices();
+ return renderApp(params);
+ },
+ });
+ }
+
+ public start() {}
+
+ public stop() {}
+}
+
+export type CorePluginDeprecationsPluginSetup = ReturnType;
+export type CorePluginDeprecationsPluginStart = ReturnType;
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/server/config.ts b/test/plugin_functional/plugins/core_plugin_deprecations/server/config.ts
new file mode 100644
index 0000000000000..db4288d26a3d7
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/server/config.ts
@@ -0,0 +1,41 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { schema, TypeOf } from '@kbn/config-schema';
+import { get } from 'lodash';
+import type { PluginConfigDescriptor } from 'kibana/server';
+import type { ConfigDeprecation } from '@kbn/config';
+
+const configSchema = schema.object({
+ newProperty: schema.maybe(schema.string({ defaultValue: 'Some string' })),
+ noLongerUsed: schema.maybe(schema.string()),
+ secret: schema.maybe(schema.number({ defaultValue: 42 })),
+});
+
+type ConfigType = TypeOf;
+
+const configSecretDeprecation: ConfigDeprecation = (settings, fromPath, addDeprecation) => {
+ if (get(settings, 'corePluginDeprecations.secret') !== 42) {
+ addDeprecation({
+ documentationUrl: 'config-secret-doc-url',
+ message:
+ 'Kibana plugin funcitonal tests will no longer allow corePluginDeprecations.secret ' +
+ 'config to be set to anything except 42.',
+ });
+ }
+ return settings;
+};
+
+export const config: PluginConfigDescriptor = {
+ schema: configSchema,
+ deprecations: ({ rename, unused }) => [
+ rename('oldProperty', 'newProperty'),
+ unused('noLongerUsed'),
+ configSecretDeprecation,
+ ],
+};
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts b/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts
new file mode 100644
index 0000000000000..1968c011a327a
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/server/index.ts
@@ -0,0 +1,12 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { CorePluginDeprecationsPlugin } from './plugin';
+
+export { config } from './config';
+export const plugin = () => new CorePluginDeprecationsPlugin();
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/server/plugin.ts b/test/plugin_functional/plugins/core_plugin_deprecations/server/plugin.ts
new file mode 100644
index 0000000000000..38565b1e2c0a8
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/server/plugin.ts
@@ -0,0 +1,57 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import type { Plugin, CoreSetup, GetDeprecationsContext, DeprecationsDetails } from 'kibana/server';
+import { registerRoutes } from './routes';
+async function getDeprecations({
+ savedObjectsClient,
+}: GetDeprecationsContext): Promise {
+ const deprecations: DeprecationsDetails[] = [];
+ const { total } = await savedObjectsClient.find({ type: 'test-deprecations-plugin', perPage: 1 });
+
+ deprecations.push({
+ message: `CorePluginDeprecationsPlugin is a deprecated feature for testing.`,
+ documentationUrl: 'test-url',
+ level: 'warning',
+ correctiveActions: {
+ manualSteps: ['Step a', 'Step b'],
+ },
+ });
+
+ if (total > 0) {
+ deprecations.push({
+ message: `SavedObject test-deprecations-plugin is still being used.`,
+ documentationUrl: 'another-test-url',
+ level: 'critical',
+ correctiveActions: {},
+ });
+ }
+
+ return deprecations;
+}
+
+export class CorePluginDeprecationsPlugin implements Plugin {
+ public setup(core: CoreSetup, deps: {}) {
+ registerRoutes(core.http);
+ core.savedObjects.registerType({
+ name: 'test-deprecations-plugin',
+ hidden: false,
+ namespaceType: 'single',
+ mappings: {
+ properties: {
+ title: { type: 'text' },
+ },
+ },
+ });
+
+ core.deprecations.registerDeprecations({ getDeprecations });
+ }
+
+ public start() {}
+ public stop() {}
+}
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/server/routes.ts b/test/plugin_functional/plugins/core_plugin_deprecations/server/routes.ts
new file mode 100644
index 0000000000000..d6bf065898f93
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/server/routes.ts
@@ -0,0 +1,45 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import type { HttpServiceSetup } from 'kibana/server';
+import { schema } from '@kbn/config-schema';
+
+export function registerRoutes(http: HttpServiceSetup) {
+ const router = http.createRouter();
+ router.post(
+ {
+ path: '/api/core_deprecations_resolve/',
+ validate: {
+ body: schema.object({
+ mockFail: schema.maybe(schema.boolean()),
+ keyId: schema.maybe(schema.string()),
+ deprecationDetails: schema.object({
+ domainId: schema.string(),
+ }),
+ }),
+ },
+ },
+ async (context, req, res) => {
+ const { mockFail, keyId } = req.body;
+ if (mockFail === true) {
+ return res.badRequest({
+ body: new Error('Mocking api failure'),
+ });
+ }
+
+ if (keyId) {
+ const client = context.core.savedObjects.getClient();
+ await client.delete('test-deprecations-plugin', keyId, {
+ refresh: true,
+ });
+ }
+
+ return res.ok();
+ }
+ );
+}
diff --git a/test/plugin_functional/plugins/core_plugin_deprecations/tsconfig.json b/test/plugin_functional/plugins/core_plugin_deprecations/tsconfig.json
new file mode 100644
index 0000000000000..3d9d8ca9451d4
--- /dev/null
+++ b/test/plugin_functional/plugins/core_plugin_deprecations/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "extends": "../../../../tsconfig.base.json",
+ "compilerOptions": {
+ "outDir": "./target",
+ "skipLibCheck": true
+ },
+ "include": [
+ "index.ts",
+ "public/**/*.ts",
+ "public/**/*.tsx",
+ "server/**/*.ts",
+ "../../../../typings/**/*",
+ ],
+ "exclude": [],
+ "references": [
+ { "path": "../../../../src/core/tsconfig.json" }
+ ]
+}
diff --git a/test/plugin_functional/test_suites/core/deprecations.ts b/test/plugin_functional/test_suites/core/deprecations.ts
new file mode 100644
index 0000000000000..c44781ab284c6
--- /dev/null
+++ b/test/plugin_functional/test_suites/core/deprecations.ts
@@ -0,0 +1,247 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import expect from '@kbn/expect';
+import type { DomainDeprecationDetails, DeprecationsGetResponse } from 'src/core/server/types';
+import type { ResolveDeprecationResponse } from 'src/core/public';
+import { PluginFunctionalProviderContext } from '../../services';
+
+export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) {
+ const supertest = getService('supertest');
+ const esArchiver = getService('esArchiver');
+ const PageObjects = getPageObjects(['common']);
+ const browser = getService('browser');
+
+ const CorePluginDeprecationsPluginDeprecations = [
+ {
+ level: 'critical',
+ message:
+ '"corePluginDeprecations.oldProperty" is deprecated and has been replaced by "corePluginDeprecations.newProperty"',
+ correctiveActions: {
+ manualSteps: [
+ 'Replace "corePluginDeprecations.oldProperty" with "corePluginDeprecations.newProperty" in the Kibana config file, CLI flag, or environment variable (in Docker only).',
+ ],
+ },
+ domainId: 'corePluginDeprecations',
+ },
+ {
+ level: 'critical',
+ message: 'corePluginDeprecations.noLongerUsed is deprecated and is no longer used',
+ correctiveActions: {
+ manualSteps: [
+ 'Remove "corePluginDeprecations.noLongerUsed" from the Kibana config file, CLI flag, or environment variable (in Docker only)',
+ ],
+ },
+ domainId: 'corePluginDeprecations',
+ },
+ {
+ level: 'critical',
+ message:
+ 'Kibana plugin funcitonal tests will no longer allow corePluginDeprecations.secret config to be set to anything except 42.',
+ correctiveActions: {},
+ documentationUrl: 'config-secret-doc-url',
+ domainId: 'corePluginDeprecations',
+ },
+ {
+ message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
+ documentationUrl: 'test-url',
+ level: 'warning',
+ correctiveActions: {
+ manualSteps: ['Step a', 'Step b'],
+ },
+ domainId: 'corePluginDeprecations',
+ },
+ {
+ message: 'SavedObject test-deprecations-plugin is still being used.',
+ documentationUrl: 'another-test-url',
+ level: 'critical',
+ correctiveActions: {},
+ domainId: 'corePluginDeprecations',
+ },
+ ];
+
+ describe('deprecations service', () => {
+ before(() => esArchiver.load('../functional/fixtures/es_archiver/deprecations_service'));
+ after(() => esArchiver.unload('../functional/fixtures/es_archiver/deprecations_service'));
+
+ describe('GET /api/deprecations/', async () => {
+ it('returns registered config deprecations and feature deprecations', async () => {
+ const { body } = await supertest.get('/api/deprecations/').set('kbn-xsrf', 'true');
+
+ const { deprecations } = body as DeprecationsGetResponse;
+ expect(Array.isArray(deprecations)).to.be(true);
+ const corePluginDeprecations = deprecations.filter(
+ ({ domainId }) => domainId === 'corePluginDeprecations'
+ );
+
+ expect(corePluginDeprecations).to.eql(CorePluginDeprecationsPluginDeprecations);
+ });
+ });
+
+ describe('Public API', () => {
+ before(async () => await PageObjects.common.navigateToApp('home'));
+
+ it('#getAllDeprecations returns all deprecations plugin deprecations', async () => {
+ const result = await browser.executeAsync((cb) => {
+ return window._coreProvider.start.core.deprecations.getAllDeprecations().then(cb);
+ });
+
+ const corePluginDeprecations = result.filter(
+ ({ domainId }) => domainId === 'corePluginDeprecations'
+ );
+
+ expect(corePluginDeprecations).to.eql(CorePluginDeprecationsPluginDeprecations);
+ });
+
+ it('#getDeprecations returns domain deprecations', async () => {
+ const corePluginDeprecations = await browser.executeAsync(
+ (cb) => {
+ return window._coreProvider.start.core.deprecations
+ .getDeprecations('corePluginDeprecations')
+ .then(cb);
+ }
+ );
+
+ expect(corePluginDeprecations).to.eql(CorePluginDeprecationsPluginDeprecations);
+ });
+
+ describe('resolveDeprecation', () => {
+ it('fails on missing correctiveActions.api', async () => {
+ const resolveResult = await browser.executeAsync((cb) => {
+ return window._coreProvider.start.core.deprecations
+ .resolveDeprecation({
+ message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
+ documentationUrl: 'test-url',
+ level: 'warning',
+ correctiveActions: {
+ manualSteps: ['Step a', 'Step b'],
+ },
+ domainId: 'corePluginDeprecations',
+ })
+ .then(cb);
+ });
+
+ expect(resolveResult).to.eql({
+ reason: 'deprecation has no correctiveAction via api.',
+ status: 'fail',
+ });
+ });
+
+ it('fails on bad request from correctiveActions.api', async () => {
+ const resolveResult = await browser.executeAsync((cb) => {
+ return window._coreProvider.start.core.deprecations
+ .resolveDeprecation({
+ message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
+ documentationUrl: 'test-url',
+ level: 'warning',
+ correctiveActions: {
+ api: {
+ method: 'POST',
+ path: '/api/core_deprecations_resolve/',
+ body: {
+ mockFail: true,
+ },
+ },
+ },
+ domainId: 'corePluginDeprecations',
+ })
+ .then(cb);
+ });
+
+ expect(resolveResult).to.eql({
+ reason: 'Mocking api failure',
+ status: 'fail',
+ });
+ });
+
+ it('fails on 404 request from correctiveActions.api', async () => {
+ const resolveResult = await browser.executeAsync((cb) => {
+ return window._coreProvider.start.core.deprecations
+ .resolveDeprecation({
+ message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
+ documentationUrl: 'test-url',
+ level: 'warning',
+ correctiveActions: {
+ api: {
+ method: 'POST',
+ path: '/api/invalid_route_not_registered/',
+ body: {
+ mockFail: true,
+ },
+ },
+ },
+ domainId: 'corePluginDeprecations',
+ })
+ .then(cb);
+ });
+
+ expect(resolveResult).to.eql({
+ reason: 'Not Found',
+ status: 'fail',
+ });
+ });
+
+ it('returns { status: ok } on successful correctiveActions.api', async () => {
+ const savedObjectId = await supertest
+ .get('/api/saved_objects/_find?type=test-deprecations-plugin')
+ .set('kbn-xsrf', 'true')
+ .expect(200)
+ .then(({ body }) => {
+ expect(body.total).to.be(1);
+ return body.saved_objects[0].id;
+ });
+
+ const resolveResult = await browser.executeAsync(
+ (keyId, cb) => {
+ return window._coreProvider.start.core.deprecations
+ .resolveDeprecation({
+ message: 'CorePluginDeprecationsPlugin is a deprecated feature for testing.',
+ documentationUrl: 'test-url',
+ level: 'warning',
+ correctiveActions: {
+ api: {
+ method: 'POST',
+ path: '/api/core_deprecations_resolve/',
+ body: { keyId },
+ },
+ },
+ domainId: 'corePluginDeprecations',
+ })
+ .then(cb);
+ },
+ savedObjectId
+ );
+
+ expect(resolveResult).to.eql({ status: 'ok' });
+ await supertest
+ .get('/api/saved_objects/_find?type=test-deprecations-plugin')
+ .set('kbn-xsrf', 'true')
+ .expect(200)
+ .then(({ body }) => {
+ expect(body.total).to.be(0);
+ });
+
+ const { deprecations } = await supertest
+ .get('/api/deprecations/')
+ .set('kbn-xsrf', 'true')
+ .then(
+ ({ body }): Promise => {
+ return body;
+ }
+ );
+
+ const deprecation = deprecations.find(
+ ({ message }) => message === 'SavedObject test-deprecations-plugin is still being used.'
+ );
+
+ expect(deprecation).to.eql(undefined);
+ });
+ });
+ });
+ });
+}
diff --git a/test/plugin_functional/test_suites/core/index.ts b/test/plugin_functional/test_suites/core/index.ts
index 9baa1ab0b394d..8591c2fdec8dd 100644
--- a/test/plugin_functional/test_suites/core/index.ts
+++ b/test/plugin_functional/test_suites/core/index.ts
@@ -10,6 +10,7 @@ import { PluginFunctionalProviderContext } from '../../services';
export default function ({ loadTestFile }: PluginFunctionalProviderContext) {
describe('core', function () {
+ loadTestFile(require.resolve('./deprecations'));
loadTestFile(require.resolve('./route'));
});
}
diff --git a/x-pack/plugins/monitoring/server/deprecations.test.js b/x-pack/plugins/monitoring/server/deprecations.test.js
index d7e1a2340d295..2931f704a4478 100644
--- a/x-pack/plugins/monitoring/server/deprecations.test.js
+++ b/x-pack/plugins/monitoring/server/deprecations.test.js
@@ -16,8 +16,8 @@ describe('monitoring plugin deprecations', function () {
beforeAll(function () {
const deprecations = deprecationsModule({ rename, renameFromRoot });
- transformDeprecations = (settings, fromPath, log = noop) => {
- deprecations.forEach((deprecation) => deprecation(settings, fromPath, log));
+ transformDeprecations = (settings, fromPath, addDeprecation = noop) => {
+ deprecations.forEach((deprecation) => deprecation(settings, fromPath, addDeprecation));
};
});
@@ -31,9 +31,9 @@ describe('monitoring plugin deprecations', function () {
},
};
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).not.toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).not.toHaveBeenCalled();
});
it(`shouldn't log when email_address is specified`, function () {
@@ -46,9 +46,9 @@ describe('monitoring plugin deprecations', function () {
},
};
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).not.toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).not.toHaveBeenCalled();
});
it(`should log when email_address is missing, but alerts/notifications are both enabled`, function () {
@@ -60,9 +60,9 @@ describe('monitoring plugin deprecations', function () {
},
};
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).toHaveBeenCalled();
});
});
@@ -70,65 +70,65 @@ describe('monitoring plugin deprecations', function () {
it('logs a warning if elasticsearch.username is set to "elastic"', () => {
const settings = { elasticsearch: { username: 'elastic' } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).toHaveBeenCalled();
});
it('logs a warning if elasticsearch.username is set to "kibana"', () => {
const settings = { elasticsearch: { username: 'kibana' } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).toHaveBeenCalled();
});
it('does not log a warning if elasticsearch.username is set to something besides "elastic" or "kibana"', () => {
const settings = { elasticsearch: { username: 'otheruser' } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).not.toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).not.toHaveBeenCalled();
});
it('does not log a warning if elasticsearch.username is unset', () => {
const settings = { elasticsearch: { username: undefined } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).not.toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).not.toHaveBeenCalled();
});
it('logs a warning if ssl.key is set and ssl.certificate is not', () => {
const settings = { elasticsearch: { ssl: { key: '' } } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).toHaveBeenCalled();
});
it('logs a warning if ssl.certificate is set and ssl.key is not', () => {
const settings = { elasticsearch: { ssl: { certificate: '' } } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).toHaveBeenCalled();
});
it('does not log a warning if both ssl.key and ssl.certificate are set', () => {
const settings = { elasticsearch: { ssl: { key: '', certificate: '' } } };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
- expect(log).not.toHaveBeenCalled();
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
+ expect(addDeprecation).not.toHaveBeenCalled();
});
});
describe('xpack_api_polling_frequency_millis', () => {
it('should call rename for this renamed config key', () => {
const settings = { xpack_api_polling_frequency_millis: 30000 };
- const log = jest.fn();
- transformDeprecations(settings, fromPath, log);
+ const addDeprecation = jest.fn();
+ transformDeprecations(settings, fromPath, addDeprecation);
expect(rename).toHaveBeenCalled();
});
});
diff --git a/x-pack/plugins/monitoring/server/deprecations.ts b/x-pack/plugins/monitoring/server/deprecations.ts
index a276cfcee0d35..79b879b3a5f8b 100644
--- a/x-pack/plugins/monitoring/server/deprecations.ts
+++ b/x-pack/plugins/monitoring/server/deprecations.ts
@@ -44,41 +44,41 @@ export const deprecations = ({
'monitoring.ui.elasticsearch.logFetchCount'
),
renameFromRoot('xpack.monitoring', 'monitoring'),
- (config, fromPath, logger) => {
+ (config, fromPath, addDeprecation) => {
const emailNotificationsEnabled = get(config, 'cluster_alerts.email_notifications.enabled');
if (emailNotificationsEnabled && !get(config, CLUSTER_ALERTS_ADDRESS_CONFIG_KEY)) {
- logger(
- `Config key [${fromPath}.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}] will be required for email notifications to work in 7.0."`
- );
+ addDeprecation({
+ message: `Config key [${fromPath}.${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}] will be required for email notifications to work in 7.0."`,
+ });
}
return config;
},
- (config, fromPath, logger) => {
+ (config, fromPath, addDeprecation) => {
const es: Record = get(config, 'elasticsearch');
if (es) {
if (es.username === 'elastic') {
- logger(
- `Setting [${fromPath}.username] to "elastic" is deprecated. You should use the "kibana_system" user instead.`
- );
+ addDeprecation({
+ message: `Setting [${fromPath}.username] to "elastic" is deprecated. You should use the "kibana_system" user instead.`,
+ });
} else if (es.username === 'kibana') {
- logger(
- `Setting [${fromPath}.username] to "kibana" is deprecated. You should use the "kibana_system" user instead.`
- );
+ addDeprecation({
+ message: `Setting [${fromPath}.username] to "kibana" is deprecated. You should use the "kibana_system" user instead.`,
+ });
}
}
return config;
},
- (config, fromPath, logger) => {
+ (config, fromPath, addDeprecation) => {
const ssl: Record = get(config, 'elasticsearch.ssl');
if (ssl) {
if (ssl.key !== undefined && ssl.certificate === undefined) {
- logger(
- `Setting [${fromPath}.key] without [${fromPath}.certificate] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.`
- );
+ addDeprecation({
+ message: `Setting [${fromPath}.key] without [${fromPath}.certificate] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.`,
+ });
} else if (ssl.certificate !== undefined && ssl.key === undefined) {
- logger(
- `Setting [${fromPath}.certificate] without [${fromPath}.key] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.`
- );
+ addDeprecation({
+ message: `Setting [${fromPath}.certificate] without [${fromPath}.key] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.`,
+ });
}
}
return config;
diff --git a/x-pack/plugins/reporting/server/config/index.test.ts b/x-pack/plugins/reporting/server/config/index.test.ts
index d7c12937cda7c..a395cd23288eb 100644
--- a/x-pack/plugins/reporting/server/config/index.test.ts
+++ b/x-pack/plugins/reporting/server/config/index.test.ts
@@ -21,7 +21,7 @@ const applyReportingDeprecations = (settings: Record = {}) => {
deprecation,
path: CONFIG_PATH,
})),
- (msg) => deprecationMessages.push(msg)
+ () => ({ message }) => deprecationMessages.push(message)
);
return {
messages: deprecationMessages,
diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts
index 06975aa85f1e4..4b97dbc1e2a84 100644
--- a/x-pack/plugins/reporting/server/config/index.ts
+++ b/x-pack/plugins/reporting/server/config/index.ts
@@ -24,12 +24,12 @@ export const config: PluginConfigDescriptor = {
unused('poll.jobCompletionNotifier.intervalErrorMultiplier'),
unused('poll.jobsRefresh.intervalErrorMultiplier'),
unused('kibanaApp'),
- (settings, fromPath, log) => {
+ (settings, fromPath, addDeprecation) => {
const reporting = get(settings, fromPath);
if (reporting?.index) {
- log(
- `"${fromPath}.index" is deprecated. Multitenancy by changing "kibana.index" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details`
- );
+ addDeprecation({
+ message: `"${fromPath}.index" is deprecated. Multitenancy by changing "kibana.index" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details`,
+ });
}
return settings;
},
diff --git a/x-pack/plugins/security/server/config_deprecations.test.ts b/x-pack/plugins/security/server/config_deprecations.test.ts
index 2b6ad603e6163..80173dd42a49e 100644
--- a/x-pack/plugins/security/server/config_deprecations.test.ts
+++ b/x-pack/plugins/security/server/config_deprecations.test.ts
@@ -20,7 +20,7 @@ const applyConfigDeprecations = (settings: Record = {}) => {
deprecation,
path: 'xpack.security',
})),
- (msg) => deprecationMessages.push(msg)
+ () => ({ message }) => deprecationMessages.push(message)
);
return {
messages: deprecationMessages,
diff --git a/x-pack/plugins/security/server/config_deprecations.ts b/x-pack/plugins/security/server/config_deprecations.ts
index a7bb5e09fb919..eae996fe2a5c0 100644
--- a/x-pack/plugins/security/server/config_deprecations.ts
+++ b/x-pack/plugins/security/server/config_deprecations.ts
@@ -22,16 +22,17 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
unused('authorization.legacyFallback.enabled'),
unused('authc.saml.maxRedirectURLSize'),
// Deprecation warning for the old array-based format of `xpack.security.authc.providers`.
- (settings, fromPath, log) => {
+ (settings, fromPath, addDeprecation) => {
if (Array.isArray(settings?.xpack?.security?.authc?.providers)) {
- log(
- 'Defining `xpack.security.authc.providers` as an array of provider types is deprecated. Use extended `object` format instead.'
- );
+ addDeprecation({
+ message:
+ 'Defining `xpack.security.authc.providers` as an array of provider types is deprecated. Use extended `object` format instead.',
+ });
}
return settings;
},
- (settings, fromPath, log) => {
+ (settings, fromPath, addDeprecation) => {
const hasProviderType = (providerType: string) => {
const providers = settings?.xpack?.security?.authc?.providers;
if (Array.isArray(providers)) {
@@ -44,31 +45,34 @@ export const securityConfigDeprecationProvider: ConfigDeprecationProvider = ({
};
if (hasProviderType('basic') && hasProviderType('token')) {
- log(
- 'Enabling both `basic` and `token` authentication providers in `xpack.security.authc.providers` is deprecated. Login page will only use `token` provider.'
- );
+ addDeprecation({
+ message:
+ 'Enabling both `basic` and `token` authentication providers in `xpack.security.authc.providers` is deprecated. Login page will only use `token` provider.',
+ });
}
return settings;
},
- (settings, fromPath, log) => {
+ (settings, fromPath, addDeprecation) => {
const samlProviders = (settings?.xpack?.security?.authc?.providers?.saml ?? {}) as Record<
string,
any
>;
if (Object.values(samlProviders).find((provider) => !!provider.maxRedirectURLSize)) {
- log(
- '`xpack.security.authc.providers.saml..maxRedirectURLSize` is deprecated and is no longer used'
- );
+ addDeprecation({
+ message:
+ '`xpack.security.authc.providers.saml..maxRedirectURLSize` is deprecated and is no longer used',
+ });
}
return settings;
},
- (settings, fromPath, log) => {
+ (settings, fromPath, addDeprecation) => {
if (settings?.xpack?.security?.enabled === false) {
- log(
- 'Disabling the security plugin (`xpack.security.enabled`) will not be supported in the next major version (8.0). ' +
- 'To turn off security features, disable them in Elasticsearch instead.'
- );
+ addDeprecation({
+ message:
+ 'Disabling the security plugin (`xpack.security.enabled`) will not be supported in the next major version (8.0). ' +
+ 'To turn off security features, disable them in Elasticsearch instead.',
+ });
}
return settings;
},
diff --git a/x-pack/plugins/spaces/server/config.test.ts b/x-pack/plugins/spaces/server/config.test.ts
index 41c4995b5bcf3..1ce1be0698b1c 100644
--- a/x-pack/plugins/spaces/server/config.test.ts
+++ b/x-pack/plugins/spaces/server/config.test.ts
@@ -19,7 +19,7 @@ const applyConfigDeprecations = (settings: Record = {}) => {
deprecation,
path: '',
})),
- (msg) => deprecationMessages.push(msg)
+ () => ({ message }) => deprecationMessages.push(message)
);
return {
messages: deprecationMessages,
diff --git a/x-pack/plugins/spaces/server/config.ts b/x-pack/plugins/spaces/server/config.ts
index bc53f43c3e8c4..ed541fda6c292 100644
--- a/x-pack/plugins/spaces/server/config.ts
+++ b/x-pack/plugins/spaces/server/config.ts
@@ -24,11 +24,11 @@ export function createConfig$(context: PluginInitializerContext) {
return context.config.create>();
}
-const disabledDeprecation: ConfigDeprecation = (config, fromPath, log) => {
+const disabledDeprecation: ConfigDeprecation = (config, fromPath, addDeprecation) => {
if (config.xpack?.spaces?.enabled === false) {
- log(
- `Disabling the spaces plugin (xpack.spaces.enabled) will not be supported in the next major version (8.0)`
- );
+ addDeprecation({
+ message: `Disabling the spaces plugin (xpack.spaces.enabled) will not be supported in the next major version (8.0)`,
+ });
}
return config;
};
diff --git a/x-pack/plugins/task_manager/server/index.test.ts b/x-pack/plugins/task_manager/server/index.test.ts
index 470b47b40f67d..3fce5f7bdfdf4 100644
--- a/x-pack/plugins/task_manager/server/index.test.ts
+++ b/x-pack/plugins/task_manager/server/index.test.ts
@@ -22,7 +22,7 @@ const applyTaskManagerDeprecations = (settings: Record = {}) =>
deprecation,
path: CONFIG_PATH,
})),
- (msg) => deprecationMessages.push(msg)
+ () => ({ message }) => deprecationMessages.push(message)
);
return {
messages: deprecationMessages,
diff --git a/x-pack/plugins/task_manager/server/index.ts b/x-pack/plugins/task_manager/server/index.ts
index 6d744010757f5..a34f5a87fddbe 100644
--- a/x-pack/plugins/task_manager/server/index.ts
+++ b/x-pack/plugins/task_manager/server/index.ts
@@ -31,17 +31,18 @@ export {
export const config: PluginConfigDescriptor = {
schema: configSchema,
deprecations: () => [
- (settings, fromPath, log) => {
+ (settings, fromPath, addDeprecation) => {
const taskManager = get(settings, fromPath);
if (taskManager?.index) {
- log(
- `"${fromPath}.index" is deprecated. Multitenancy by changing "kibana.index" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details`
- );
+ addDeprecation({
+ documentationUrl: 'https://ela.st/kbn-remove-legacy-multitenancy',
+ message: `"${fromPath}.index" is deprecated. Multitenancy by changing "kibana.index" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details`,
+ });
}
if (taskManager?.max_workers > MAX_WORKERS_LIMIT) {
- log(
- `setting "${fromPath}.max_workers" (${taskManager?.max_workers}) greater than ${MAX_WORKERS_LIMIT} is deprecated. Values greater than ${MAX_WORKERS_LIMIT} will not be supported starting in 8.0.`
- );
+ addDeprecation({
+ message: `setting "${fromPath}.max_workers" (${taskManager?.max_workers}) greater than ${MAX_WORKERS_LIMIT} is deprecated. Values greater than ${MAX_WORKERS_LIMIT} will not be supported starting in 8.0.`,
+ });
}
return settings;
},