From 647d98c7d56495f0a06abb59b979a6781929e2c5 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Fri, 18 Jun 2021 01:30:07 +0000 Subject: [PATCH] [Build] deprecate renamed configurations While renaming after the fork, configurations were renamed and replaced with keywords related to OpenSearch. This meant that anyone who migrated to OpenSearch Dashboards who had configured their YAML file no longer were able to carry over those changes and run the application. This prevented the application from starting due to unknown config keys. Although, this still does not allow the application to work out of the box because people will need to make sure then rename their kibana.yml to opensearch_dashboards.yml, but once they do they do not need to modify the content of the config. Issues resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/440 Partially resolves: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/334 Signed-off-by: Kawika Avilla --- .../server/opensearch/opensearch_config.ts | 19 +++++++++++++++++- .../server/opensearch_dashboards_config.ts | 12 +++++++++++ src/plugins/home/server/index.ts | 1 + src/plugins/maps_legacy/server/index.ts | 8 ++++++++ .../server/index.ts | 6 +++++- src/plugins/region_map/server/index.ts | 6 ++++++ src/plugins/vis_type_timeline/server/index.ts | 20 +++++++++++++++++-- src/plugins/vis_type_vega/server/index.ts | 2 +- 8 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/core/server/opensearch/opensearch_config.ts b/src/core/server/opensearch/opensearch_config.ts index eac35cdf0b1e..4bffca8b4b14 100644 --- a/src/core/server/opensearch/opensearch_config.ts +++ b/src/core/server/opensearch/opensearch_config.ts @@ -135,7 +135,24 @@ export const configSchema = schema.object({ ), }); -const deprecations: ConfigDeprecationProvider = () => [ +const deprecations: ConfigDeprecationProvider = ({ renameFromRoot }) => [ + renameFromRoot('elasticsearch.sniffOnStart', 'opensearch.sniffOnStart'), + renameFromRoot('elasticsearch.sniffInterval', 'opensearch.sniffInterval'), + renameFromRoot('elasticsearch.sniffOnConnectionFault', 'opensearch.sniffOnConnectionFault'), + renameFromRoot('elasticsearch.hosts', 'opensearch.hosts'), + renameFromRoot('elasticsearch.username', 'opensearch.username'), + renameFromRoot('elasticsearch.password', 'opensearch.password'), + renameFromRoot('elasticsearch.requestHeadersWhitelist', 'opensearch.requestHeadersWhitelist'), + renameFromRoot('elasticsearch.customHeaders', 'opensearch.customHeaders'), + renameFromRoot('elasticsearch.shardTimeout', 'opensearch.shardTimeout'), + renameFromRoot('elasticsearch.requestTimeout', 'opensearch.requestTimeout'), + renameFromRoot('elasticsearch.pingTimeout', 'opensearch.pingTimeout'), + renameFromRoot('elasticsearch.logQueries', 'opensearch.logQueries'), + renameFromRoot('elasticsearch.optimizedHealthcheckId', 'opensearch.optimizedHealthcheckId'), + renameFromRoot('elasticsearch.ssl', 'opensearch.ssl'), + renameFromRoot('elasticsearch.apiVersion', 'opensearch.apiVersion'), + renameFromRoot('elasticsearch.healthCheck', 'opensearch.healthCheck'), + renameFromRoot('elasticsearch.ignoreVersionMismatch', 'opensearch.ignoreVersionMismatch'), (settings, fromPath, log) => { const opensearch = settings[fromPath]; if (!opensearch) { diff --git a/src/core/server/opensearch_dashboards_config.ts b/src/core/server/opensearch_dashboards_config.ts index b549be8dd539..3f9415212be2 100644 --- a/src/core/server/opensearch_dashboards_config.ts +++ b/src/core/server/opensearch_dashboards_config.ts @@ -31,9 +31,20 @@ */ import { schema, TypeOf } from '@osd/config-schema'; +import { ConfigDeprecationProvider } from 'packages/osd-config'; export type OpenSearchDashboardsConfigType = TypeOf; +const deprecations: ConfigDeprecationProvider = ({ renameFromRoot }) => [ + renameFromRoot('kibana.enabled', 'opensearchDashboards.enabled'), + renameFromRoot('kibana.index', 'opensearchDashboards.index'), + renameFromRoot( + 'kibana.autocompleteTerminateAfter', + 'opensearchDashboards.autocompleteTerminateAfter' + ), + renameFromRoot('kibana.autocompleteTimeout', 'opensearchDashboards.autocompleteTimeout'), +]; + export const config = { path: 'opensearchDashboards', schema: schema.object({ @@ -42,4 +53,5 @@ export const config = { autocompleteTerminateAfter: schema.duration({ defaultValue: 100000 }), autocompleteTimeout: schema.duration({ defaultValue: 1000 }), }), + deprecations, }; diff --git a/src/plugins/home/server/index.ts b/src/plugins/home/server/index.ts index 48cbbb23e97c..7bfbae652542 100644 --- a/src/plugins/home/server/index.ts +++ b/src/plugins/home/server/index.ts @@ -44,6 +44,7 @@ export const config: PluginConfigDescriptor = { schema: configSchema, deprecations: ({ renameFromRoot }) => [ renameFromRoot('opensearchDashboards.disableWelcomeScreen', 'home.disableWelcomeScreen'), + renameFromRoot('kibana.disableWelcomeScreen', 'home.disableWelcomeScreen'), ], }; diff --git a/src/plugins/maps_legacy/server/index.ts b/src/plugins/maps_legacy/server/index.ts index bad2223e927d..404beeb6d32b 100644 --- a/src/plugins/maps_legacy/server/index.ts +++ b/src/plugins/maps_legacy/server/index.ts @@ -51,6 +51,14 @@ export const config: PluginConfigDescriptor = { emsTileLayerId: true, }, schema: configSchema, + deprecations: ({ renameFromRoot }) => [ + renameFromRoot('map.includeElasticMapsService', 'map.includeOpenSearchMapsService'), + renameFromRoot('map.proxyOpenSearchMapsServiceInMaps', 'map.proxyElasticMapsServiceInMaps'), + renameFromRoot( + 'map.regionmap.includeElasticMapsService', + 'map.regionmap.includeOpenSearchMapsService' + ), + ], }; export interface MapsLegacyPluginSetup { diff --git a/src/plugins/opensearch_dashboards_legacy/server/index.ts b/src/plugins/opensearch_dashboards_legacy/server/index.ts index 8f029634193a..24667343541e 100644 --- a/src/plugins/opensearch_dashboards_legacy/server/index.ts +++ b/src/plugins/opensearch_dashboards_legacy/server/index.ts @@ -52,10 +52,14 @@ export const config: PluginConfigDescriptor = { 'opensearch_dashboards_legacy.defaultAppId', true ), + renameFromRoot('kibana.defaultAppId', 'opensearch_dashboards_legacy.defaultAppId', true), + renameFromRoot('kibana_legacy.defaultAppId', 'opensearch_dashboards_legacy.defaultAppId', true), (completeConfig: Record, rootPath: string, log: ConfigDeprecationLogger) => { if ( get(completeConfig, 'opensearchDashboards.defaultAppId') === undefined && - get(completeConfig, 'opensearch_dashboards_legacy.defaultAppId') === undefined + get(completeConfig, 'opensearch_dashboards_legacy.defaultAppId') === undefined && + get(completeConfig, 'kibana.defaultAppId') === undefined && + get(completeConfig, 'kibana_legacy.defaultAppId') === undefined ) { return completeConfig; } diff --git a/src/plugins/region_map/server/index.ts b/src/plugins/region_map/server/index.ts index 07d31773280d..a39e28fe2c66 100644 --- a/src/plugins/region_map/server/index.ts +++ b/src/plugins/region_map/server/index.ts @@ -41,6 +41,12 @@ export const config: PluginConfigDescriptor = { layers: true, }, schema: configSchema, + deprecations: ({ renameFromRoot }) => [ + renameFromRoot( + 'map.regionmap.includeElasticMapsService', + 'map.regionmap.includeOpenSearchMapsService' + ), + ], }; export const plugin = () => ({ diff --git a/src/plugins/vis_type_timeline/server/index.ts b/src/plugins/vis_type_timeline/server/index.ts index a0e8ec745b15..ac3859f2b4f8 100644 --- a/src/plugins/vis_type_timeline/server/index.ts +++ b/src/plugins/vis_type_timeline/server/index.ts @@ -42,10 +42,26 @@ export const config: PluginConfigDescriptor = { ui: true, }, deprecations: ({ renameFromRoot }) => [ - renameFromRoot('timeline_vis.enabled', 'vis_type_timeline.enabled'), + // timelion.enabled and timelion_vis.enabled deprecation + renameFromRoot('timelion.enabled', 'vis_type_timeline.enabled'), + renameFromRoot('timelion_vis.enabled', 'vis_type_timeline.enabled'), + renameFromRoot('vis_type_timelion.enabled', 'vis_type_timeline.enabled'), renameFromRoot('timeline.enabled', 'vis_type_timeline.enabled'), - renameFromRoot('timeline.graphiteUrls', 'vis_type_timeline.graphiteUrls'), + renameFromRoot('timeline_vis.enabled', 'vis_type_timeline.enabled'), + + // timelion.graphiteUrls deprecation + renameFromRoot('timelion.graphiteUrls', 'vis_type_timeline.graphiteAllowedUrls'), + renameFromRoot('vis_type_timelion.graphiteUrls', 'vis_type_timeline.graphiteAllowedUrls'), + renameFromRoot( + 'vis_type_timelion.graphiteAllowedUrls', + 'vis_type_timeline.graphiteAllowedUrls' + ), + renameFromRoot('timeline.graphiteUrls', 'vis_type_timeline.graphiteAllowedUrls'), renameFromRoot('vis_type_timeline.graphiteUrls', 'vis_type_timeline.graphiteAllowedUrls'), + + // timelion.ui.enabled deprecation + renameFromRoot('timelion.ui.enabled', 'vis_type_timeline.ui.enabled', true), + renameFromRoot('vis_type_timelion.ui.enabled', 'vis_type_timeline.ui.enabled', true), renameFromRoot('timeline.ui.enabled', 'vis_type_timeline.ui.enabled', true), ], }; diff --git a/src/plugins/vis_type_vega/server/index.ts b/src/plugins/vis_type_vega/server/index.ts index 84cf00c792f2..4b39ba46cdd1 100644 --- a/src/plugins/vis_type_vega/server/index.ts +++ b/src/plugins/vis_type_vega/server/index.ts @@ -30,7 +30,7 @@ * GitHub history for details. */ -import { PluginConfigDescriptor, PluginInitializerContext } from 'opensearch_dashboards/server'; +import { PluginConfigDescriptor, PluginInitializerContext } from 'opensearch-dashboards/server'; import { configSchema, ConfigSchema } from '../config'; import { VisTypeVegaPlugin } from './plugin';