[Deprecations service] Expose level
field to config deprecations (#111516)
This commit is contained in:
parent
764256573a
commit
b001830d58
|
@ -23,6 +23,12 @@ export interface DeprecatedConfigDetails {
|
||||||
title?: string;
|
title?: string;
|
||||||
/* The message to be displayed for the deprecation. */
|
/* The message to be displayed for the deprecation. */
|
||||||
message: string;
|
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. */
|
/* (optional) set false to prevent the config service from logging the deprecation message. */
|
||||||
silent?: boolean;
|
silent?: boolean;
|
||||||
/* (optional) link to the documentation for more details on the deprecation. */
|
/* (optional) link to the documentation for more details on the deprecation. */
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe('DeprecationsService', () => {
|
||||||
const deprecationsRegistry = mockDeprecationsRegistry.create();
|
const deprecationsRegistry = mockDeprecationsRegistry.create();
|
||||||
const getDeprecationsContext = mockDeprecationsRegistry.createGetDeprecationsContext();
|
const getDeprecationsContext = mockDeprecationsRegistry.createGetDeprecationsContext();
|
||||||
|
|
||||||
it('registers config deprecations', () => {
|
it('registers config deprecations', async () => {
|
||||||
const deprecationsService = new DeprecationsService(coreContext);
|
const deprecationsService = new DeprecationsService(coreContext);
|
||||||
coreContext.configService.getHandledDeprecatedConfigs.mockReturnValue([
|
coreContext.configService.getHandledDeprecatedConfigs.mockReturnValue([
|
||||||
[
|
[
|
||||||
|
@ -93,7 +93,7 @@ describe('DeprecationsService', () => {
|
||||||
expect(deprecationsFactory.getRegistry).toBeCalledTimes(1);
|
expect(deprecationsFactory.getRegistry).toBeCalledTimes(1);
|
||||||
expect(deprecationsFactory.getRegistry).toBeCalledWith('testDomain');
|
expect(deprecationsFactory.getRegistry).toBeCalledWith('testDomain');
|
||||||
expect(deprecationsRegistry.registerDeprecations).toBeCalledTimes(1);
|
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
|
getDeprecationsContext
|
||||||
);
|
);
|
||||||
expect(configDeprecations).toMatchInlineSnapshot(`
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -186,17 +186,21 @@ export class DeprecationsService
|
||||||
deprecationsRegistry.registerDeprecations({
|
deprecationsRegistry.registerDeprecations({
|
||||||
getDeprecations: () => {
|
getDeprecations: () => {
|
||||||
return deprecationsContexts.map(
|
return deprecationsContexts.map(
|
||||||
({ title, message, correctiveActions, documentationUrl }) => {
|
({
|
||||||
return {
|
title = `${domainId} has a deprecated setting`,
|
||||||
title: title || `${domainId} has a deprecated setting`,
|
level = 'critical',
|
||||||
level: 'critical',
|
message,
|
||||||
deprecationType: 'config',
|
correctiveActions,
|
||||||
message,
|
documentationUrl,
|
||||||
correctiveActions,
|
}) => ({
|
||||||
documentationUrl,
|
title,
|
||||||
requireRestart: true,
|
level,
|
||||||
};
|
message,
|
||||||
}
|
correctiveActions,
|
||||||
|
documentationUrl,
|
||||||
|
deprecationType: 'config',
|
||||||
|
requireRestart: true,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue