From e69f28b5d2fc1ec546248d0812345d2f0a1747e8 Mon Sep 17 00:00:00 2001 From: kobelb Date: Fri, 20 Nov 2020 15:10:46 -0800 Subject: [PATCH 1/5] Deprecating `xpack.reporting.index` setting --- x-pack/plugins/reporting/server/config/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts index b9c6f8e7591e34..3a4f2e6c970822 100644 --- a/x-pack/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { get } from 'lodash'; import { PluginConfigDescriptor } from 'kibana/server'; import { ConfigSchema, ReportingConfigType } from './schema'; export { buildConfig } from './config'; @@ -20,5 +21,14 @@ export const config: PluginConfigDescriptor = { unused('poll.jobCompletionNotifier.intervalErrorMultiplier'), unused('poll.jobsRefresh.intervalErrorMultiplier'), unused('kibanaApp'), + (settings, fromPath, log) => { + const reporting = get(settings, fromPath); + if (reporting?.index) { + log( + `Setting [xpack.reporting.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; + }, ], }; From ef00c4d876902903485cde16fad5c3f5ce9b5e66 Mon Sep 17 00:00:00 2001 From: kobelb Date: Fri, 20 Nov 2020 15:15:34 -0800 Subject: [PATCH 2/5] Adding unit test --- .../reporting/server/config/index.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 x-pack/plugins/reporting/server/config/index.test.ts diff --git a/x-pack/plugins/reporting/server/config/index.test.ts b/x-pack/plugins/reporting/server/config/index.test.ts new file mode 100644 index 00000000000000..fc2ab8ec0753db --- /dev/null +++ b/x-pack/plugins/reporting/server/config/index.test.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { config } from './index'; +import { applyDeprecations, configDeprecationFactory } from '@kbn/config'; + +const CONFIG_PATH = 'kibana'; + +const applyReportingDeprecations = (settings: Record = {}) => { + const deprecations = config.deprecations!(configDeprecationFactory); + const deprecationMessages: string[] = []; + const _config: any = {}; + _config[CONFIG_PATH] = settings; + const migrated = applyDeprecations( + _config, + deprecations.map((deprecation) => ({ + deprecation, + path: CONFIG_PATH, + })), + (msg) => deprecationMessages.push(msg) + ); + return { + messages: deprecationMessages, + migrated, + }; +}; + +describe('deprecations', () => { + ['.foo', '.reporting'].forEach((index) => { + it('logs a warning if index is set', () => { + const { messages } = applyReportingDeprecations({ index }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "Setting [xpack.reporting.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", + ] + `); + }); + }); +}); From 88844e72486d7801b9895da8fa84ef6d495b95fa Mon Sep 17 00:00:00 2001 From: kobelb Date: Mon, 23 Nov 2020 11:53:27 -0800 Subject: [PATCH 3/5] Now with more standard deprecation messages --- x-pack/plugins/reporting/server/config/index.test.ts | 2 +- x-pack/plugins/reporting/server/config/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/reporting/server/config/index.test.ts b/x-pack/plugins/reporting/server/config/index.test.ts index fc2ab8ec0753db..5cff587d39b5db 100644 --- a/x-pack/plugins/reporting/server/config/index.test.ts +++ b/x-pack/plugins/reporting/server/config/index.test.ts @@ -34,7 +34,7 @@ describe('deprecations', () => { const { messages } = applyReportingDeprecations({ index }); expect(messages).toMatchInlineSnapshot(` Array [ - "Setting [xpack.reporting.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", + "\\"xpack.reporting.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", ] `); }); diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts index 3a4f2e6c970822..e92f5d10bf551e 100644 --- a/x-pack/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/index.ts @@ -25,7 +25,7 @@ export const config: PluginConfigDescriptor = { const reporting = get(settings, fromPath); if (reporting?.index) { log( - `Setting [xpack.reporting.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` + `"xpack.reporting.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; From 6f8383373e164eba0c15d71c19d24f5b6be5f236 Mon Sep 17 00:00:00 2001 From: kobelb Date: Mon, 23 Nov 2020 11:59:47 -0800 Subject: [PATCH 4/5] Updating the xpack.reporting.index docs --- docs/settings/reporting-settings.asciidoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/settings/reporting-settings.asciidoc b/docs/settings/reporting-settings.asciidoc index d44c42db92f41d..2d91eb07c5236c 100644 --- a/docs/settings/reporting-settings.asciidoc +++ b/docs/settings/reporting-settings.asciidoc @@ -261,7 +261,9 @@ For information about {kib} memory limits, see <> setting. Defaults to `.reporting`. From 761b5b00017c5a6a0386cd9e3aaa3ebcfb264387 Mon Sep 17 00:00:00 2001 From: kobelb Date: Mon, 23 Nov 2020 12:35:50 -0800 Subject: [PATCH 5/5] Fixing tests --- x-pack/plugins/reporting/server/config/index.test.ts | 2 +- x-pack/plugins/reporting/server/config/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/reporting/server/config/index.test.ts b/x-pack/plugins/reporting/server/config/index.test.ts index 5cff587d39b5db..ac20ed6c303d70 100644 --- a/x-pack/plugins/reporting/server/config/index.test.ts +++ b/x-pack/plugins/reporting/server/config/index.test.ts @@ -7,7 +7,7 @@ import { config } from './index'; import { applyDeprecations, configDeprecationFactory } from '@kbn/config'; -const CONFIG_PATH = 'kibana'; +const CONFIG_PATH = 'xpack.reporting'; const applyReportingDeprecations = (settings: Record = {}) => { const deprecations = config.deprecations!(configDeprecationFactory); diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts index e92f5d10bf551e..9ec06df7e69b92 100644 --- a/x-pack/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/index.ts @@ -25,7 +25,7 @@ export const config: PluginConfigDescriptor = { const reporting = get(settings, fromPath); if (reporting?.index) { log( - `"xpack.reporting.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` + `"${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;