Remove default value for deprecation level (#123411)

* Remove default value for deprecation level

* add missing levels

* update tsdoc

* fix test levels

* another missing level

* fix more types

* change console.ssl deprecation level to critical
This commit is contained in:
Pierre Gayvallet 2022-01-26 08:02:33 +01:00 committed by GitHub
parent 49d0f2eafc
commit 5dbe2737cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 139 additions and 87 deletions

View file

@ -434,11 +434,13 @@ test('logs deprecation warning during validation', async () => {
const addDeprecation = createAddDeprecation!('');
addDeprecation({
configPath: 'test1',
level: 'warning',
message: 'some deprecation message',
correctiveActions: { manualSteps: ['do X'] },
});
addDeprecation({
configPath: 'test2',
level: 'warning',
message: 'another deprecation message',
correctiveActions: { manualSteps: ['do Y'] },
});
@ -505,12 +507,14 @@ test('does not log warnings for silent deprecations during validation', async ()
const addDeprecation = createAddDeprecation!('');
addDeprecation({
configPath: 'test1',
level: 'warning',
message: 'some deprecation message',
correctiveActions: { manualSteps: ['do X'] },
silent: true,
});
addDeprecation({
configPath: 'test2',
level: 'warning',
message: 'another deprecation message',
correctiveActions: { manualSteps: ['do Y'] },
});
@ -520,6 +524,7 @@ test('does not log warnings for silent deprecations during validation', async ()
const addDeprecation = createAddDeprecation!('');
addDeprecation({
configPath: 'silent',
level: 'warning',
message: 'I am silent',
silent: true,
correctiveActions: { manualSteps: ['do Z'] },
@ -597,13 +602,16 @@ describe('getHandledDeprecatedConfigs', () => {
const rawConfig = getRawConfigProvider({ base: { unused: 'unusedConfig' } });
const configService = new ConfigService(rawConfig, defaultEnv, logger);
configService.addDeprecationProvider('base', ({ unused }) => [unused('unused')]);
configService.addDeprecationProvider('base', ({ unused }) => [
unused('unused', { level: 'warning' }),
]);
mockApplyDeprecations.mockImplementationOnce((config, deprecations, createAddDeprecation) => {
deprecations.forEach((deprecation) => {
const addDeprecation = createAddDeprecation!(deprecation.path);
addDeprecation({
configPath: 'test1',
level: 'warning',
message: `some deprecation message`,
documentationUrl: 'some-url',
correctiveActions: { manualSteps: ['do X'] },
@ -627,6 +635,7 @@ describe('getHandledDeprecatedConfigs', () => {
],
},
"documentationUrl": "some-url",
"level": "warning",
"message": "some deprecation message",
},
],

View file

@ -109,8 +109,8 @@ describe('applyDeprecations', () => {
const initialConfig = { foo: 'bar', deprecated: 'deprecated', renamed: 'renamed' };
const { config: migrated } = applyDeprecations(initialConfig, [
wrapHandler(deprecations.unused('deprecated')),
wrapHandler(deprecations.rename('renamed', 'newname')),
wrapHandler(deprecations.unused('deprecated', { level: 'critical' })),
wrapHandler(deprecations.rename('renamed', 'newname', { level: 'critical' })),
]);
expect(migrated).toEqual({ foo: 'bar', newname: 'renamed' });
@ -131,8 +131,10 @@ describe('applyDeprecations', () => {
};
const { config: migrated } = applyDeprecations(initialConfig, [
wrapHandler(deprecations.unused('deprecated.nested')),
wrapHandler(deprecations.rename('nested.from.rename', 'nested.to.renamed')),
wrapHandler(deprecations.unused('deprecated.nested', { level: 'critical' })),
wrapHandler(
deprecations.rename('nested.from.rename', 'nested.to.renamed', { level: 'critical' })
),
]);
expect(migrated).toStrictEqual({
@ -150,7 +152,7 @@ describe('applyDeprecations', () => {
const initialConfig = { foo: 'bar', deprecated: 'deprecated' };
const { config: migrated } = applyDeprecations(initialConfig, [
wrapHandler(deprecations.unused('deprecated')),
wrapHandler(deprecations.unused('deprecated', { level: 'critical' })),
]);
expect(initialConfig).toEqual({ foo: 'bar', deprecated: 'deprecated' });

View file

@ -32,7 +32,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = deprecate('deprecated', '8.0.0')(
const commands = deprecate('deprecated', '8.0.0', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
@ -49,6 +49,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only) before upgrading to 8.0.0.",
],
},
"level": "critical",
"message": "Configuring \\"myplugin.deprecated\\" is deprecated and will be removed in 8.0.0.",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -69,7 +70,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = deprecate('section.deprecated', '8.0.0')(
const commands = deprecate('section.deprecated', '8.0.0', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
@ -86,6 +87,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.section.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only) before upgrading to 8.0.0.",
],
},
"level": "critical",
"message": "Configuring \\"myplugin.section.deprecated\\" is deprecated and will be removed in 8.0.0.",
"title": "Setting \\"myplugin.section.deprecated\\" is deprecated",
},
@ -103,7 +105,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = deprecate('deprecated', '8.0.0')(
const commands = deprecate('deprecated', '8.0.0', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
@ -125,7 +127,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = deprecateFromRoot('myplugin.deprecated', '8.0.0')(
const commands = deprecateFromRoot('myplugin.deprecated', '8.0.0', { level: 'critical' })(
rawConfig,
'does-not-matter',
addDeprecation,
@ -142,6 +144,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only) before upgrading to 8.0.0.",
],
},
"level": "critical",
"message": "Configuring \\"myplugin.deprecated\\" is deprecated and will be removed in 8.0.0.",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -159,7 +162,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = deprecateFromRoot('myplugin.deprecated', '8.0.0')(
const commands = deprecateFromRoot('myplugin.deprecated', '8.0.0', { level: 'critical' })(
rawConfig,
'does-not-matter',
addDeprecation,
@ -181,7 +184,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = rename('deprecated', 'renamed')(
const commands = rename('deprecated', 'renamed', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
@ -206,6 +209,7 @@ describe('DeprecationFactory', () => {
"Replace \\"myplugin.deprecated\\" with \\"myplugin.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "Setting \\"myplugin.deprecated\\" has been replaced by \\"myplugin.renamed\\"",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -223,7 +227,12 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = rename('deprecated', 'new')(rawConfig, 'myplugin', addDeprecation, context);
const commands = rename('deprecated', 'new', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
context
);
expect(commands).toBeUndefined();
expect(addDeprecation).toHaveBeenCalledTimes(0);
});
@ -239,7 +248,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = rename('oldsection.deprecated', 'newsection.renamed')(
const commands = rename('oldsection.deprecated', 'newsection.renamed', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
@ -264,6 +273,7 @@ describe('DeprecationFactory', () => {
"Replace \\"myplugin.oldsection.deprecated\\" with \\"myplugin.newsection.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "Setting \\"myplugin.oldsection.deprecated\\" has been replaced by \\"myplugin.newsection.renamed\\"",
"title": "Setting \\"myplugin.oldsection.deprecated\\" is deprecated",
},
@ -278,7 +288,7 @@ describe('DeprecationFactory', () => {
renamed: 'renamed',
},
};
const commands = rename('deprecated', 'renamed')(
const commands = rename('deprecated', 'renamed', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
@ -298,6 +308,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.deprecated\\" from the config.",
],
},
"level": "critical",
"message": "Setting \\"myplugin.deprecated\\" has been replaced by \\"myplugin.renamed\\". However, both keys are present. Ignoring \\"myplugin.deprecated\\"",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -318,12 +329,9 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = renameFromRoot('myplugin.deprecated', 'myplugin.renamed')(
rawConfig,
'does-not-matter',
addDeprecation,
context
);
const commands = renameFromRoot('myplugin.deprecated', 'myplugin.renamed', {
level: 'critical',
})(rawConfig, 'does-not-matter', addDeprecation, context);
expect(commands).toEqual({
set: [
{
@ -343,6 +351,7 @@ describe('DeprecationFactory', () => {
"Replace \\"myplugin.deprecated\\" with \\"myplugin.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "Setting \\"myplugin.deprecated\\" has been replaced by \\"myplugin.renamed\\"",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -361,12 +370,9 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = renameFromRoot('oldplugin.deprecated', 'newplugin.renamed')(
rawConfig,
'does-not-matter',
addDeprecation,
context
);
const commands = renameFromRoot('oldplugin.deprecated', 'newplugin.renamed', {
level: 'critical',
})(rawConfig, 'does-not-matter', addDeprecation, context);
expect(commands).toEqual({
set: [
{
@ -386,6 +392,7 @@ describe('DeprecationFactory', () => {
"Replace \\"oldplugin.deprecated\\" with \\"newplugin.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "Setting \\"oldplugin.deprecated\\" has been replaced by \\"newplugin.renamed\\"",
"title": "Setting \\"oldplugin.deprecated\\" is deprecated",
},
@ -404,7 +411,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = renameFromRoot('myplugin.deprecated', 'myplugin.new')(
const commands = renameFromRoot('myplugin.deprecated', 'myplugin.new', { level: 'critical' })(
rawConfig,
'does-not-matter',
addDeprecation,
@ -421,12 +428,9 @@ describe('DeprecationFactory', () => {
renamed: 'renamed',
},
};
const commands = renameFromRoot('myplugin.deprecated', 'myplugin.renamed')(
rawConfig,
'does-not-matter',
addDeprecation,
context
);
const commands = renameFromRoot('myplugin.deprecated', 'myplugin.renamed', {
level: 'critical',
})(rawConfig, 'does-not-matter', addDeprecation, context);
expect(commands).toEqual({
unset: [{ path: 'myplugin.deprecated' }],
});
@ -442,6 +446,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.deprecated\\" from the config.",
],
},
"level": "critical",
"message": "Setting \\"myplugin.deprecated\\" has been replaced by \\"myplugin.renamed\\". However, both keys are present. Ignoring \\"myplugin.deprecated\\"",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -462,7 +467,12 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = unused('deprecated')(rawConfig, 'myplugin', addDeprecation, context);
const commands = unused('deprecated', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
context
);
expect(commands).toEqual({
unset: [{ path: 'myplugin.deprecated' }],
});
@ -476,6 +486,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "You no longer need to configure \\"myplugin.deprecated\\".",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -496,7 +507,12 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = unused('section.deprecated')(rawConfig, 'myplugin', addDeprecation, context);
const commands = unused('section.deprecated', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
context
);
expect(commands).toEqual({
unset: [{ path: 'myplugin.section.deprecated' }],
});
@ -510,6 +526,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.section.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "You no longer need to configure \\"myplugin.section.deprecated\\".",
"title": "Setting \\"myplugin.section.deprecated\\" is deprecated",
},
@ -527,7 +544,12 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = unused('deprecated')(rawConfig, 'myplugin', addDeprecation, context);
const commands = unused('deprecated', { level: 'critical' })(
rawConfig,
'myplugin',
addDeprecation,
context
);
expect(commands).toBeUndefined();
expect(addDeprecation).toBeCalledTimes(0);
});
@ -544,7 +566,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = unusedFromRoot('myplugin.deprecated')(
const commands = unusedFromRoot('myplugin.deprecated', { level: 'critical' })(
rawConfig,
'does-not-matter',
addDeprecation,
@ -563,6 +585,7 @@ describe('DeprecationFactory', () => {
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only).",
],
},
"level": "critical",
"message": "You no longer need to configure \\"myplugin.deprecated\\".",
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
},
@ -580,7 +603,7 @@ describe('DeprecationFactory', () => {
property: 'value',
},
};
const commands = unusedFromRoot('myplugin.deprecated')(
const commands = unusedFromRoot('myplugin.deprecated', { level: 'critical' })(
rawConfig,
'does-not-matter',
addDeprecation,

View file

@ -13,7 +13,7 @@ import {
ConfigDeprecation,
AddConfigDeprecation,
ConfigDeprecationFactory,
DeprecatedConfigDetails,
FactoryConfigDeprecationDetails,
ConfigDeprecationCommand,
} from './types';
@ -30,7 +30,7 @@ const _deprecate = (
addDeprecation: AddConfigDeprecation,
deprecatedKey: string,
removeBy: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): void => {
const fullPath = getPath(rootPath, deprecatedKey);
if (get(config, fullPath) === undefined) {
@ -62,7 +62,7 @@ const _rename = (
addDeprecation: AddConfigDeprecation,
oldKey: string,
newKey: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): void | ConfigDeprecationCommand => {
const fullOldPath = getPath(rootPath, oldKey);
const oldValue = get(config, fullOldPath);
@ -131,7 +131,7 @@ const _unused = (
rootPath: string,
addDeprecation: AddConfigDeprecation,
unusedKey: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): void | ConfigDeprecationCommand => {
const fullPath = getPath(rootPath, unusedKey);
if (get(config, fullPath) === undefined) {
@ -164,7 +164,7 @@ const deprecate =
(
unusedKey: string,
removeBy: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): ConfigDeprecation =>
(config, rootPath, addDeprecation) =>
_deprecate(config, rootPath, addDeprecation, unusedKey, removeBy, details);
@ -173,28 +173,28 @@ const deprecateFromRoot =
(
unusedKey: string,
removeBy: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): ConfigDeprecation =>
(config, rootPath, addDeprecation) =>
_deprecate(config, '', addDeprecation, unusedKey, removeBy, details);
const rename =
(oldKey: string, newKey: string, details?: Partial<DeprecatedConfigDetails>): ConfigDeprecation =>
(oldKey: string, newKey: string, details: FactoryConfigDeprecationDetails): ConfigDeprecation =>
(config, rootPath, addDeprecation) =>
_rename(config, rootPath, addDeprecation, oldKey, newKey, details);
const renameFromRoot =
(oldKey: string, newKey: string, details?: Partial<DeprecatedConfigDetails>): ConfigDeprecation =>
(oldKey: string, newKey: string, details: FactoryConfigDeprecationDetails): ConfigDeprecation =>
(config, rootPath, addDeprecation) =>
_rename(config, '', addDeprecation, oldKey, newKey, details);
const unused =
(unusedKey: string, details?: Partial<DeprecatedConfigDetails>): ConfigDeprecation =>
(unusedKey: string, details: FactoryConfigDeprecationDetails): ConfigDeprecation =>
(config, rootPath, addDeprecation) =>
_unused(config, rootPath, addDeprecation, unusedKey, details);
const unusedFromRoot =
(unusedKey: string, details?: Partial<DeprecatedConfigDetails>): ConfigDeprecation =>
(unusedKey: string, details: FactoryConfigDeprecationDetails): ConfigDeprecation =>
(config, rootPath, addDeprecation) =>
_unused(config, '', addDeprecation, unusedKey, details);

View file

@ -31,7 +31,7 @@ export interface DeprecatedConfigDetails {
* - warning: will not break deployment upon upgrade
* - critical: needs to be addressed before upgrade.
*/
level?: 'warning' | 'critical';
level: 'warning' | 'critical';
/** (optional) set to `true` to prevent the config service from logging the deprecation message. */
silent?: boolean;
/** (optional) link to the documentation for more details on the deprecation. */
@ -107,9 +107,9 @@ export interface ConfigDeprecationCommand {
* @example
* ```typescript
* const provider: ConfigDeprecationProvider = ({ deprecate, rename, unused }) => [
* deprecate('deprecatedKey', '8.0.0'),
* rename('oldKey', 'newKey'),
* unused('deprecatedKey'),
* deprecate('deprecatedKey', '8.0.0', { level: 'warning' }),
* rename('oldKey', 'newKey', { level: 'warning' }),
* unused('deprecatedKey', { level: 'warning' }),
* (config, path) => ({ unset: [{ key: 'path.to.key' }] })
* ]
* ```
@ -118,6 +118,10 @@ export interface ConfigDeprecationCommand {
*/
export type ConfigDeprecationProvider = (factory: ConfigDeprecationFactory) => ConfigDeprecation[];
/** @public */
export type FactoryConfigDeprecationDetails = Pick<DeprecatedConfigDetails, 'level'> &
Partial<Omit<DeprecatedConfigDetails, 'level'>>;
/**
* Provides helpers to generates the most commonly used {@link ConfigDeprecation}
* when invoking a {@link ConfigDeprecationProvider}.
@ -127,8 +131,8 @@ export type ConfigDeprecationProvider = (factory: ConfigDeprecationFactory) => C
* @example
* ```typescript
* const provider: ConfigDeprecationProvider = ({ rename, unused }) => [
* rename('oldKey', 'newKey'),
* unused('deprecatedKey'),
* rename('oldKey', 'newKey', { level: 'critical' }),
* unused('deprecatedKey', { level: 'warning' }),
* ]
* ```
*
@ -144,14 +148,14 @@ export interface ConfigDeprecationFactory {
* Log a deprecation warning indicating 'myplugin.deprecatedKey' should be removed by `8.0.0`
* ```typescript
* const provider: ConfigDeprecationProvider = ({ deprecate }) => [
* deprecate('deprecatedKey', '8.0.0'),
* deprecate('deprecatedKey', '8.0.0', { level: 'critical' }),
* ]
* ```
*/
deprecate(
deprecatedKey: string,
removeBy: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): ConfigDeprecation;
/**
@ -165,14 +169,14 @@ export interface ConfigDeprecationFactory {
* Log a deprecation warning indicating 'myplugin.deprecatedKey' should be removed by `8.0.0`
* ```typescript
* const provider: ConfigDeprecationProvider = ({ deprecateFromRoot }) => [
* deprecateFromRoot('deprecatedKey', '8.0.0'),
* deprecateFromRoot('deprecatedKey', '8.0.0', { level: 'critical' }),
* ]
* ```
*/
deprecateFromRoot(
deprecatedKey: string,
removeBy: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): ConfigDeprecation;
/**
@ -183,7 +187,7 @@ export interface ConfigDeprecationFactory {
* Rename 'myplugin.oldKey' to 'myplugin.newKey'
* ```typescript
* const provider: ConfigDeprecationProvider = ({ rename }) => [
* rename('oldKey', 'newKey'),
* rename('oldKey', 'newKey', { level: 'warning' }),
* ]
* ```
*
@ -209,7 +213,7 @@ export interface ConfigDeprecationFactory {
rename(
oldKey: string,
newKey: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): ConfigDeprecation;
/**
@ -223,7 +227,7 @@ export interface ConfigDeprecationFactory {
* Rename 'oldplugin.key' to 'newplugin.key'
* ```typescript
* const provider: ConfigDeprecationProvider = ({ renameFromRoot }) => [
* renameFromRoot('oldplugin.key', 'newplugin.key'),
* renameFromRoot('oldplugin.key', 'newplugin.key', { level: 'critical' }),
* ]
* ```
*
@ -249,7 +253,7 @@ export interface ConfigDeprecationFactory {
renameFromRoot(
oldKey: string,
newKey: string,
details?: Partial<DeprecatedConfigDetails>
details: FactoryConfigDeprecationDetails
): ConfigDeprecation;
/**
@ -260,7 +264,7 @@ export interface ConfigDeprecationFactory {
* Flags 'myplugin.deprecatedKey' as unused
* ```typescript
* const provider: ConfigDeprecationProvider = ({ unused }) => [
* unused('deprecatedKey'),
* unused('deprecatedKey', { level: 'warning' }),
* ]
* ```
*
@ -283,7 +287,7 @@ export interface ConfigDeprecationFactory {
* }
* ```
*/
unused(unusedKey: string, details?: Partial<DeprecatedConfigDetails>): ConfigDeprecation;
unused(unusedKey: string, details: FactoryConfigDeprecationDetails): ConfigDeprecation;
/**
* Remove a configuration property from the root configuration.
@ -296,7 +300,7 @@ export interface ConfigDeprecationFactory {
* Flags 'somepath.deprecatedProperty' as unused
* ```typescript
* const provider: ConfigDeprecationProvider = ({ unusedFromRoot }) => [
* unusedFromRoot('somepath.deprecatedProperty'),
* unusedFromRoot('somepath.deprecatedProperty', { level: 'warning' }),
* ]
* ```
*
@ -319,7 +323,7 @@ export interface ConfigDeprecationFactory {
* }
* ```
*/
unusedFromRoot(unusedKey: string, details?: Partial<DeprecatedConfigDetails>): ConfigDeprecation;
unusedFromRoot(unusedKey: string, details: FactoryConfigDeprecationDetails): ConfigDeprecation;
}
/** @internal */

View file

@ -101,6 +101,7 @@ describe('DeprecationsService', () => {
[
{
configPath: 'test',
level: 'critical',
message: 'testMessage',
documentationUrl: 'testDocUrl',
correctiveActions: {

View file

@ -206,7 +206,7 @@ export class DeprecationsService
({
configPath,
title = `${domainId} has a deprecated setting`,
level = 'critical',
level,
message,
correctiveActions,
documentationUrl,

View file

@ -246,6 +246,7 @@ const deprecations: ConfigDeprecationProvider = () => [
if (es.logQueries === true) {
addDeprecation({
configPath: `${fromPath}.logQueries`,
level: 'warning',
message: `Setting [${fromPath}.logQueries] is deprecated and no longer used. You should set the log level to "debug" for the "elasticsearch.query" context in "logging.loggers".`,
correctiveActions: {
manualSteps: [

View file

@ -180,7 +180,7 @@ export type HttpConfigType = TypeOf<typeof configSchema>;
export const config: ServiceConfigDescriptor<HttpConfigType> = {
path: 'server' as const,
schema: configSchema,
deprecations: ({ rename }) => [rename('maxPayloadBytes', 'maxPayload')],
deprecations: ({ rename }) => [rename('maxPayloadBytes', 'maxPayload', { level: 'warning' })],
};
export class HttpConfig implements IHttpConfig {

View file

@ -293,6 +293,7 @@ describe('PluginsService', () => {
);
expect(standardMockPluginSystem.addPlugin).not.toHaveBeenCalled();
}
async function expectSuccess() {
await expect(pluginsService.discover({ environment: environmentPreboot })).resolves.toEqual(
expect.anything()
@ -1099,7 +1100,9 @@ describe('PluginsService', () => {
renamed: schema.string(), // Mandatory string to make sure that the field is actually renamed by deprecations
}),
deprecations: ({ renameFromRoot }) => [
renameFromRoot('plugin-1-deprecations.toBeRenamed', 'plugin-2-deprecations.renamed'),
renameFromRoot('plugin-1-deprecations.toBeRenamed', 'plugin-2-deprecations.renamed', {
level: 'critical',
}),
],
},
}),

View file

@ -11,8 +11,8 @@ import { ConfigDeprecationProvider } from 'src/core/server';
import { ServiceConfigDescriptor } from '../internal_types';
const deprecations: ConfigDeprecationProvider = ({ unused, renameFromRoot }) => [
unused('enabled'),
renameFromRoot('server.defaultRoute', 'uiSettings.overrides.defaultRoute'),
unused('enabled', { level: 'warning' }),
renameFromRoot('server.defaultRoute', 'uiSettings.overrides.defaultRoute', { level: 'warning' }),
];
const configSchema = schema.object({

View file

@ -82,8 +82,8 @@ const config7x: PluginConfigDescriptor<ConsoleConfig7x> = {
ui: true,
},
schema: schema7x,
deprecations: ({ deprecate, unused }) => [
unused('ssl'),
deprecations: ({ unused }) => [
unused('ssl', { level: 'critical' }),
(completeConfig, rootPath, addDeprecation) => {
if (get(completeConfig, 'console.enabled') === undefined) {
return completeConfig;

View file

@ -23,6 +23,7 @@ const configSecretDeprecation: ConfigDeprecation = (settings, fromPath, addDepre
if (get(settings, 'corePluginDeprecations.secret') !== 42) {
addDeprecation({
configPath: 'corePluginDeprecations.secret',
level: 'critical',
documentationUrl: 'config-secret-doc-url',
message:
'Kibana plugin functional tests will no longer allow corePluginDeprecations.secret ' +
@ -40,8 +41,8 @@ const configSecretDeprecation: ConfigDeprecation = (settings, fromPath, addDepre
export const config: PluginConfigDescriptor<ConfigType> = {
schema: configSchema,
deprecations: ({ rename, unused }) => [
rename('oldProperty', 'newProperty'),
unused('noLongerUsed'),
rename('oldProperty', 'newProperty', { level: 'warning' }),
unused('noLongerUsed', { level: 'warning' }),
configSecretDeprecation,
],
};

View file

@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
{
configPath: 'corePluginDeprecations.oldProperty',
title: 'Setting "corePluginDeprecations.oldProperty" is deprecated',
level: 'critical',
level: 'warning',
message:
'Setting "corePluginDeprecations.oldProperty" has been replaced by "corePluginDeprecations.newProperty"',
correctiveActions: {
@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
{
configPath: 'corePluginDeprecations.noLongerUsed',
title: 'Setting "corePluginDeprecations.noLongerUsed" is deprecated',
level: 'critical',
level: 'warning',
message: 'You no longer need to configure "corePluginDeprecations.noLongerUsed".',
correctiveActions: {
manualSteps: [

View file

@ -19,7 +19,7 @@ export const config: PluginConfigDescriptor<ReportingConfigType> = {
schema: ConfigSchema,
deprecations: ({ unused }) => [
unused('capture.browser.chromium.maxScreenshotDimension', { level: 'warning' }), // unused since 7.8
unused('capture.browser.type'),
unused('capture.browser.type', { level: 'warning' }),
unused('poll.jobCompletionNotifier.intervalErrorMultiplier', { level: 'warning' }), // unused since 7.10
unused('poll.jobsRefresh.intervalErrorMultiplier', { level: 'warning' }), // unused since 7.10
unused('capture.viewport', { level: 'warning' }), // deprecated as unused since 7.16

View file

@ -9,7 +9,7 @@ import { schema, TypeOf } from '@kbn/config-schema';
import { PluginConfigDescriptor } from 'src/core/server';
export const config: PluginConfigDescriptor = {
deprecations: ({ deprecate, unused }) => [unused('unsafe.indexUpgrade.enabled')],
deprecations: ({ unused }) => [unused('unsafe.indexUpgrade.enabled', { level: 'warning' })],
schema: schema.object({
write: schema.object({
disabledRegistrationContexts: schema.arrayOf(schema.string(), { defaultValue: [] }),

View file

@ -14,30 +14,38 @@ import { ConfigSchema, ConfigType } from './schema';
export const config: PluginConfigDescriptor<ConfigType> = {
schema: ConfigSchema,
deprecations: ({ renameFromRoot }) => [
renameFromRoot('xpack.reporting.capture.networkPolicy', 'xpack.screenshotting.networkPolicy'),
renameFromRoot('xpack.reporting.capture.networkPolicy', 'xpack.screenshotting.networkPolicy', {
level: 'warning',
}),
renameFromRoot(
'xpack.reporting.capture.browser.autoDownload',
'xpack.screenshotting.browser.autoDownload'
'xpack.screenshotting.browser.autoDownload',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.inspect',
'xpack.screenshotting.browser.chromium.inspect'
'xpack.screenshotting.browser.chromium.inspect',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.disableSandbox',
'xpack.screenshotting.browser.chromium.disableSandbox'
'xpack.screenshotting.browser.chromium.disableSandbox',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.proxy.enabled',
'xpack.screenshotting.browser.chromium.proxy.enabled'
'xpack.screenshotting.browser.chromium.proxy.enabled',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.proxy.server',
'xpack.screenshotting.browser.chromium.proxy.server'
'xpack.screenshotting.browser.chromium.proxy.server',
{ level: 'warning' }
),
renameFromRoot(
'xpack.reporting.capture.browser.chromium.proxy.bypass',
'xpack.screenshotting.browser.chromium.proxy.bypass'
'xpack.screenshotting.browser.chromium.proxy.bypass',
{ level: 'warning' }
),
],
exposeToUsage: {