Skip to content

Commit

Permalink
[Build] deprecate renamed configurations
Browse files Browse the repository at this point in the history
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:
opensearch-project#440

Partially resolves:
opensearch-project#334

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Jun 18, 2021
1 parent 5fa9cb5 commit 647d98c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 5 deletions.
19 changes: 18 additions & 1 deletion src/core/server/opensearch/opensearch_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 12 additions & 0 deletions src/core/server/opensearch_dashboards_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,20 @@
*/

import { schema, TypeOf } from '@osd/config-schema';
import { ConfigDeprecationProvider } from 'packages/osd-config';

export type OpenSearchDashboardsConfigType = TypeOf<typeof config.schema>;

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({
Expand All @@ -42,4 +53,5 @@ export const config = {
autocompleteTerminateAfter: schema.duration({ defaultValue: 100000 }),
autocompleteTimeout: schema.duration({ defaultValue: 1000 }),
}),
deprecations,
};
1 change: 1 addition & 0 deletions src/plugins/home/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
schema: configSchema,
deprecations: ({ renameFromRoot }) => [
renameFromRoot('opensearchDashboards.disableWelcomeScreen', 'home.disableWelcomeScreen'),
renameFromRoot('kibana.disableWelcomeScreen', 'home.disableWelcomeScreen'),
],
};

Expand Down
8 changes: 8 additions & 0 deletions src/plugins/maps_legacy/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export const config: PluginConfigDescriptor<MapsLegacyConfig> = {
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 {
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/opensearch_dashboards_legacy/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
'opensearch_dashboards_legacy.defaultAppId',
true
),
renameFromRoot('kibana.defaultAppId', 'opensearch_dashboards_legacy.defaultAppId', true),
renameFromRoot('kibana_legacy.defaultAppId', 'opensearch_dashboards_legacy.defaultAppId', true),
(completeConfig: Record<string, any>, 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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/region_map/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
layers: true,
},
schema: configSchema,
deprecations: ({ renameFromRoot }) => [
renameFromRoot(
'map.regionmap.includeElasticMapsService',
'map.regionmap.includeOpenSearchMapsService'
),
],
};

export const plugin = () => ({
Expand Down
20 changes: 18 additions & 2 deletions src/plugins/vis_type_timeline/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,26 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
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),
],
};
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vega/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 647d98c

Please sign in to comment.