Skip to content

Commit

Permalink
Deprecate 'enabled' config for plugins with expicit config schemas.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Sep 21, 2021
1 parent 5041f8c commit 0dd26ca
Show file tree
Hide file tree
Showing 33 changed files with 118 additions and 74 deletions.
4 changes: 2 additions & 2 deletions packages/kbn-config/src/config_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ test('logs deprecation if schema is not present and "enabled" is used', async ()
Object {
"correctiveActions": Object {
"manualSteps": Array [
"Remove foo.enabled from your Kibana config.",
"Remove \\"foo.enabled\\" from the Kibana config file, CLI flag, or environment variable (in Docker only) before upgrading to 8.0.0.",
],
},
"message": "\\"foo.enabled\\" has been deprecated and will be removed in 8.0.",
"message": "Configuring \\"foo.enabled\\" is deprecated and will be removed in 8.0.0.",
"title": "Setting \\"foo.enabled\\" is deprecated",
},
],
Expand Down
6 changes: 4 additions & 2 deletions packages/kbn-config/src/config_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ export class ConfigService {
const deprecationPath = pathToString(enabledPath);
const deprecatedConfigDetails: DeprecatedConfigDetails = {
title: `Setting "${deprecationPath}" is deprecated`,
message: `"${deprecationPath}" has been deprecated and will be removed in 8.0.`,
message: `Configuring "${deprecationPath}" is deprecated and will be removed in 8.0.0.`,
correctiveActions: {
manualSteps: [`Remove ${deprecationPath} from your Kibana config.`],
manualSteps: [
`Remove "${deprecationPath}" from the Kibana config file, CLI flag, or environment variable (in Docker only) before upgrading to 8.0.0.`,
],
},
};
this.addDeprecationProvider(namespace, () => [
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/console/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export { ConsoleSetup, ConsoleStart } from './types';
export const plugin = (ctx: PluginInitializerContext) => new ConsoleServerPlugin(ctx);

export const config: PluginConfigDescriptor<ConfigType> = {
deprecations: ({ unused }) => [unused('ssl')],
deprecations: ({ deprecate, unused, rename }) => [deprecate('enabled', '8.0.0'), unused('ssl')],
schema: configSchema,
};
82 changes: 44 additions & 38 deletions x-pack/plugins/apm/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,62 @@
*/

import { schema, TypeOf } from '@kbn/config-schema';
import { PluginInitializerContext } from 'src/core/server';
import {
PluginInitializerContext,
PluginConfigDescriptor,
} from 'src/core/server';
import { APMOSSConfig } from 'src/plugins/apm_oss/server';
import { APMPlugin } from './plugin';
import { SearchAggregatedTransactionSetting } from '../common/aggregated_transactions';

const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
serviceMapEnabled: schema.boolean({ defaultValue: true }),
serviceMapFingerprintBucketSize: schema.number({ defaultValue: 100 }),
serviceMapTraceIdBucketSize: schema.number({ defaultValue: 65 }),
serviceMapFingerprintGlobalBucketSize: schema.number({
defaultValue: 1000,
}),
serviceMapTraceIdGlobalBucketSize: schema.number({ defaultValue: 6 }),
serviceMapMaxTracesPerRequest: schema.number({ defaultValue: 50 }),
autocreateApmIndexPattern: schema.boolean({ defaultValue: true }),
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
transactionGroupBucketSize: schema.number({ defaultValue: 1000 }),
maxTraceItems: schema.number({ defaultValue: 1000 }),
}),
searchAggregatedTransactions: schema.oneOf(
[
schema.literal(SearchAggregatedTransactionSetting.auto),
schema.literal(SearchAggregatedTransactionSetting.always),
schema.literal(SearchAggregatedTransactionSetting.never),
],
{ defaultValue: SearchAggregatedTransactionSetting.auto }
),
telemetryCollectionEnabled: schema.boolean({ defaultValue: true }),
metricsInterval: schema.number({ defaultValue: 30 }),
maxServiceEnvironments: schema.number({ defaultValue: 100 }),
maxServiceSelection: schema.number({ defaultValue: 50 }),
profilingEnabled: schema.boolean({ defaultValue: false }),
agent: schema.object({
migrations: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
}),
});

// plugin config
export const config = {
export const config: PluginConfigDescriptor<APMXPackConfig> = {
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
exposeToBrowser: {
serviceMapEnabled: true,
ui: true,
profilingEnabled: true,
},
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
serviceMapEnabled: schema.boolean({ defaultValue: true }),
serviceMapFingerprintBucketSize: schema.number({ defaultValue: 100 }),
serviceMapTraceIdBucketSize: schema.number({ defaultValue: 65 }),
serviceMapFingerprintGlobalBucketSize: schema.number({
defaultValue: 1000,
}),
serviceMapTraceIdGlobalBucketSize: schema.number({ defaultValue: 6 }),
serviceMapMaxTracesPerRequest: schema.number({ defaultValue: 50 }),
autocreateApmIndexPattern: schema.boolean({ defaultValue: true }),
ui: schema.object({
enabled: schema.boolean({ defaultValue: true }),
transactionGroupBucketSize: schema.number({ defaultValue: 1000 }),
maxTraceItems: schema.number({ defaultValue: 1000 }),
}),
searchAggregatedTransactions: schema.oneOf(
[
schema.literal(SearchAggregatedTransactionSetting.auto),
schema.literal(SearchAggregatedTransactionSetting.always),
schema.literal(SearchAggregatedTransactionSetting.never),
],
{ defaultValue: SearchAggregatedTransactionSetting.auto }
),
telemetryCollectionEnabled: schema.boolean({ defaultValue: true }),
metricsInterval: schema.number({ defaultValue: 30 }),
maxServiceEnvironments: schema.number({ defaultValue: 100 }),
maxServiceSelection: schema.number({ defaultValue: 50 }),
profilingEnabled: schema.boolean({ defaultValue: false }),
agent: schema.object({
migrations: schema.object({
enabled: schema.boolean({ defaultValue: false }),
}),
}),
}),
schema: configSchema,
};

export type APMXPackConfig = TypeOf<typeof config.schema>;
export type APMXPackConfig = TypeOf<typeof configSchema>;
export type APMConfig = ReturnType<typeof mergeConfigs>;

// plugin config and ui indices settings
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/cases/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const config: PluginConfigDescriptor<ConfigType> = {
exposeToBrowser: {
markdownPlugins: true,
},
deprecations: ({ renameFromRoot }) => [
deprecations: ({ deprecate, renameFromRoot }) => [
deprecate('enabled', '8.0.0'),
renameFromRoot('xpack.case.enabled', 'xpack.cases.enabled'),
],
};
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/cloud/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ export const config: PluginConfigDescriptor<CloudConfigType> = {
organization_url: true,
full_story: true,
},
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
schema: configSchema,
};
1 change: 1 addition & 0 deletions x-pack/plugins/cross_cluster_replication/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const config: PluginConfigDescriptor<CrossClusterReplicationConfig> = {
exposeToBrowser: {
ui: true,
},
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
7 changes: 5 additions & 2 deletions x-pack/plugins/encrypted_saved_objects/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { PluginInitializerContext } from 'src/core/server';
import type { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server';

import { ConfigSchema } from './config';
import { EncryptedSavedObjectsPlugin } from './plugin';
Expand All @@ -15,6 +15,9 @@ export { EncryptedSavedObjectsPluginSetup, EncryptedSavedObjectsPluginStart } fr
export { EncryptedSavedObjectsClient } from './saved_objects';
export type { IsMigrationNeededPredicate } from './create_migration';

export const config = { schema: ConfigSchema };
export const config: PluginConfigDescriptor = {
schema: ConfigSchema,
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
export const plugin = (initializerContext: PluginInitializerContext) =>
new EncryptedSavedObjectsPlugin(initializerContext);
1 change: 1 addition & 0 deletions x-pack/plugins/enterprise_search/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ export const config: PluginConfigDescriptor<ConfigType> = {
exposeToBrowser: {
host: true,
},
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
3 changes: 2 additions & 1 deletion x-pack/plugins/fleet/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const config: PluginConfigDescriptor = {
epm: true,
agents: true,
},
deprecations: ({ renameFromRoot, unused, unusedFromRoot }) => [
deprecations: ({ deprecate, renameFromRoot, unused, unusedFromRoot }) => [
deprecate('enabled', '8.0.0'),
// Fleet plugin was named ingestManager before
renameFromRoot('xpack.ingestManager.enabled', 'xpack.fleet.enabled'),
renameFromRoot('xpack.ingestManager.registryUrl', 'xpack.fleet.registryUrl'),
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/graph/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
savePolicy: true,
},
schema: configSchema,
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
1 change: 1 addition & 0 deletions x-pack/plugins/index_lifecycle_management/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const config: PluginConfigDescriptor<IndexLifecycleManagementConfig> = {
exposeToBrowser: {
ui: true,
},
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
5 changes: 3 additions & 2 deletions x-pack/plugins/index_management/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
* 2.0.
*/

import { PluginInitializerContext } from 'src/core/server';
import { PluginInitializerContext, PluginConfigDescriptor } from 'src/core/server';

import { IndexMgmtServerPlugin } from './plugin';
import { configSchema } from './config';

export const plugin = (context: PluginInitializerContext) => new IndexMgmtServerPlugin(context);

export const config = {
export const config: PluginConfigDescriptor = {
schema: configSchema,
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};

/** @public */
Expand Down
10 changes: 8 additions & 2 deletions x-pack/plugins/infra/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { Server } from '@hapi/hapi';
import { schema, TypeOf } from '@kbn/config-schema';
import { i18n } from '@kbn/i18n';
import { Logger } from '@kbn/logging';
import { CoreSetup, PluginInitializerContext, Plugin } from 'src/core/server';
import {
CoreSetup,
PluginInitializerContext,
Plugin,
PluginConfigDescriptor,
} from 'src/core/server';
import { LOGS_FEATURE_ID, METRICS_FEATURE_ID } from '../common/constants';
import { InfraStaticSourceConfiguration } from '../common/source_configuration/source_configuration';
import { inventoryViewSavedObjectType } from '../common/saved_objects/inventory_view';
Expand All @@ -36,7 +41,7 @@ import { createGetLogQueryFields } from './services/log_queries/get_log_query_fi
import { handleEsError } from '../../../../src/plugins/es_ui_shared/server';
import { RulesService } from './services/rules';

export const config = {
export const config: PluginConfigDescriptor = {
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
inventory: schema.object({
Expand All @@ -63,6 +68,7 @@ export const config = {
})
),
}),
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};

export type InfraConfig = TypeOf<typeof config.schema>;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { configSchema, ConfigSchema } from '../config';

export const config: PluginConfigDescriptor<ConfigSchema> = {
schema: configSchema,
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};

export const plugin = (initializerContext: PluginInitializerContext) =>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/license_management/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export const config: PluginConfigDescriptor<LicenseManagementConfig> = {
exposeToBrowser: {
ui: true,
},
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
7 changes: 5 additions & 2 deletions x-pack/plugins/lists/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { PluginInitializerContext } from '../../../../src/core/server';
import { PluginConfigDescriptor, PluginInitializerContext } from '../../../../src/core/server';

import { ConfigSchema } from './config';
import { ListPlugin } from './plugin';
Expand All @@ -19,6 +19,9 @@ export {
export { ExceptionListClient } from './services/exception_lists/exception_list_client';
export type { ListPluginSetup, ListsApiRequestHandlerContext } from './types';

export const config = { schema: ConfigSchema };
export const config: PluginConfigDescriptor = {
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
schema: ConfigSchema,
};
export const plugin = (initializerContext: PluginInitializerContext): ListPlugin =>
new ListPlugin(initializerContext);
1 change: 1 addition & 0 deletions x-pack/plugins/logstash/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const config: PluginConfigDescriptor = {
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};
3 changes: 2 additions & 1 deletion x-pack/plugins/maps/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const config: PluginConfigDescriptor<MapsXPackConfig> = {
preserveDrawingBuffer: true,
},
schema: configSchema,
deprecations: () => [
deprecations: ({ deprecate }) => [
deprecate('enabled', '8.0.0'),
(
completeConfig: Record<string, any>,
rootPath: string,
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/metrics_entities/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
* 2.0.
*/

import { PluginInitializerContext } from '../../../../src/core/server';
import { PluginConfigDescriptor, PluginInitializerContext } from '../../../../src/core/server';

import { ConfigSchema } from './config';
import { MetricsEntitiesPlugin } from './plugin';

// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.

export const config = { schema: ConfigSchema };
export const config: PluginConfigDescriptor = {
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
schema: ConfigSchema,
};
export const plugin = (initializerContext: PluginInitializerContext): MetricsEntitiesPlugin => {
return new MetricsEntitiesPlugin(initializerContext);
};
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/monitoring/server/deprecations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { deprecations as deprecationsModule } from './deprecations';
// TODO: tests were not running before and are not up to date
describe.skip('monitoring plugin deprecations', function () {
let transformDeprecations;
const deprecate = jest.fn(() => jest.fn());
const rename = jest.fn(() => jest.fn());
const renameFromRoot = jest.fn(() => jest.fn());
const fromPath = 'monitoring';

beforeAll(function () {
const deprecations = deprecationsModule({ rename, renameFromRoot });
const deprecations = deprecationsModule({ deprecate, rename, renameFromRoot });
transformDeprecations = (settings, fromPath, addDeprecation = noop) => {
deprecations.forEach((deprecation) => deprecation(settings, fromPath, addDeprecation));
};
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/server/deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY } from '../common/constants';
* @return {Array} array of rename operations and callback function for rename logging
*/
export const deprecations = ({
deprecate,
rename,
renameFromRoot,
}: ConfigDeprecationFactory): ConfigDeprecation[] => {
return [
deprecate('enabled', '8.0.0'),
// This order matters. The "blanket rename" needs to happen at the end
renameFromRoot('xpack.monitoring.max_bucket_size', 'monitoring.ui.max_bucket_size'),
renameFromRoot('xpack.monitoring.min_interval_seconds', 'monitoring.ui.min_interval_seconds'),
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/observability/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* eslint-disable @kbn/eslint/no_export_all */

import { schema, TypeOf } from '@kbn/config-schema';
import { PluginInitializerContext } from 'src/core/server';
import { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server';
import { ObservabilityPlugin, ObservabilityPluginSetup } from './plugin';
import { createOrUpdateIndex, Mappings } from './utils/create_or_update_index';
import { ScopedAnnotationsClient } from './lib/annotations/bootstrap_annotations';
Expand All @@ -18,9 +18,9 @@ export { rangeQuery, kqlQuery } from './utils/queries';

export * from './types';

export const config = {
export const config: PluginConfigDescriptor = {
exposeToBrowser: {
unsafe: { alertingExperience: { enabled: true }, cases: { enabled: true } },
unsafe: true,
},
schema: schema.object({
enabled: schema.boolean({ defaultValue: true }),
Expand All @@ -33,6 +33,7 @@ export const config = {
cases: schema.object({ enabled: schema.boolean({ defaultValue: false }) }),
}),
}),
deprecations: ({ deprecate }) => [deprecate('enabled', '8.0.0')],
};

export type ObservabilityConfig = TypeOf<typeof config.schema>;
Expand Down
Loading

0 comments on commit 0dd26ca

Please sign in to comment.