diff --git a/packages/kbn-config/src/deprecation/types.ts b/packages/kbn-config/src/deprecation/types.ts index 007c3ec54113..0e1f36121e50 100644 --- a/packages/kbn-config/src/deprecation/types.ts +++ b/packages/kbn-config/src/deprecation/types.ts @@ -23,6 +23,12 @@ export interface DeprecatedConfigDetails { title?: string; /* The message to be displayed for the deprecation. */ message: string; + /** + * levels: + * - warning: will not break deployment upon upgrade + * - critical: needs to be addressed before upgrade. + */ + level?: 'warning' | 'critical'; /* (optional) set false to prevent the config service from logging the deprecation message. */ silent?: boolean; /* (optional) link to the documentation for more details on the deprecation. */ diff --git a/src/core/server/deprecations/deprecations_service.test.ts b/src/core/server/deprecations/deprecations_service.test.ts index 0e8aaf3de49c..bc0dbcef4a5b 100644 --- a/src/core/server/deprecations/deprecations_service.test.ts +++ b/src/core/server/deprecations/deprecations_service.test.ts @@ -66,7 +66,7 @@ describe('DeprecationsService', () => { const deprecationsRegistry = mockDeprecationsRegistry.create(); const getDeprecationsContext = mockDeprecationsRegistry.createGetDeprecationsContext(); - it('registers config deprecations', () => { + it('registers config deprecations', async () => { const deprecationsService = new DeprecationsService(coreContext); coreContext.configService.getHandledDeprecatedConfigs.mockReturnValue([ [ @@ -93,7 +93,7 @@ describe('DeprecationsService', () => { expect(deprecationsFactory.getRegistry).toBeCalledTimes(1); expect(deprecationsFactory.getRegistry).toBeCalledWith('testDomain'); expect(deprecationsRegistry.registerDeprecations).toBeCalledTimes(1); - const configDeprecations = deprecationsRegistry.registerDeprecations.mock.calls[0][0].getDeprecations( + const configDeprecations = await deprecationsRegistry.registerDeprecations.mock.calls[0][0].getDeprecations( getDeprecationsContext ); expect(configDeprecations).toMatchInlineSnapshot(` @@ -115,5 +115,31 @@ describe('DeprecationsService', () => { ] `); }); + + it('accepts `level` field overrides', async () => { + const deprecationsService = new DeprecationsService(coreContext); + coreContext.configService.getHandledDeprecatedConfigs.mockReturnValue([ + [ + 'testDomain', + [ + { + message: 'testMessage', + level: 'warning', + correctiveActions: { + manualSteps: ['step a'], + }, + }, + ], + ], + ]); + + deprecationsFactory.getRegistry.mockReturnValue(deprecationsRegistry); + deprecationsService['registerConfigDeprecationsInfo'](deprecationsFactory); + + const configDeprecations = await deprecationsRegistry.registerDeprecations.mock.calls[0][0].getDeprecations( + getDeprecationsContext + ); + expect(configDeprecations[0].level).toBe('warning'); + }); }); }); diff --git a/src/core/server/deprecations/deprecations_service.ts b/src/core/server/deprecations/deprecations_service.ts index c41567d88a2a..f6f48d2a88b0 100644 --- a/src/core/server/deprecations/deprecations_service.ts +++ b/src/core/server/deprecations/deprecations_service.ts @@ -186,17 +186,21 @@ export class DeprecationsService deprecationsRegistry.registerDeprecations({ getDeprecations: () => { return deprecationsContexts.map( - ({ title, message, correctiveActions, documentationUrl }) => { - return { - title: title || `${domainId} has a deprecated setting`, - level: 'critical', - deprecationType: 'config', - message, - correctiveActions, - documentationUrl, - requireRestart: true, - }; - } + ({ + title = `${domainId} has a deprecated setting`, + level = 'critical', + message, + correctiveActions, + documentationUrl, + }) => ({ + title, + level, + message, + correctiveActions, + documentationUrl, + deprecationType: 'config', + requireRestart: true, + }) ); }, });