mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* omit deprecationDetails if needed it * review I * doc update Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
This commit is contained in:
parent
5a3521b9c4
commit
f6e5093c45
7 changed files with 41 additions and 4 deletions
|
@ -16,6 +16,7 @@ correctiveActions: {
|
|||
body?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
omitContextFromBody?: boolean;
|
||||
};
|
||||
manualSteps: string[];
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ export interface DeprecationsDetails
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [correctiveActions](./kibana-plugin-core-server.deprecationsdetails.correctiveactions.md) | <code>{</code><br/><code> api?: {</code><br/><code> path: string;</code><br/><code> method: 'POST' | 'PUT';</code><br/><code> body?: {</code><br/><code> [key: string]: any;</code><br/><code> };</code><br/><code> };</code><br/><code> manualSteps: string[];</code><br/><code> }</code> | corrective action needed to fix this deprecation. |
|
||||
| [correctiveActions](./kibana-plugin-core-server.deprecationsdetails.correctiveactions.md) | <code>{</code><br/><code> api?: {</code><br/><code> path: string;</code><br/><code> method: 'POST' | 'PUT';</code><br/><code> body?: {</code><br/><code> [key: string]: any;</code><br/><code> };</code><br/><code> omitContextFromBody?: boolean;</code><br/><code> };</code><br/><code> manualSteps: string[];</code><br/><code> }</code> | corrective action needed to fix this deprecation. |
|
||||
| [deprecationType](./kibana-plugin-core-server.deprecationsdetails.deprecationtype.md) | <code>'config' | 'feature'</code> | (optional) Used to identify between different deprecation types. Example use case: in Upgrade Assistant, we may want to allow the user to sort by deprecation type or show each type in a separate tab.<!-- -->Feel free to add new types if necessary. Predefined types are necessary to reduce having similar definitions with different keywords across kibana deprecations. |
|
||||
| [documentationUrl](./kibana-plugin-core-server.deprecationsdetails.documentationurl.md) | <code>string</code> | (optional) link to the documentation for more details on the deprecation. |
|
||||
| [level](./kibana-plugin-core-server.deprecationsdetails.level.md) | <code>'warning' | 'critical' | 'fetch_error'</code> | levels: - warning: will not break deployment upon upgrade - critical: needs to be addressed before upgrade. - fetch\_error: Deprecations service failed to grab the deprecation details for the domain. |
|
||||
|
|
|
@ -197,5 +197,38 @@ describe('DeprecationsClient', () => {
|
|||
|
||||
expect(result).toEqual({ status: 'fail', reason: mockResponse });
|
||||
});
|
||||
|
||||
it('omit deprecationDetails in the request of the body', async () => {
|
||||
const deprecationsClient = new DeprecationsClient({ http });
|
||||
const mockDeprecationDetails: DomainDeprecationDetails = {
|
||||
title: 'some-title',
|
||||
domainId: 'testPluginId-1',
|
||||
message: 'some-message',
|
||||
level: 'warning',
|
||||
correctiveActions: {
|
||||
api: {
|
||||
path: 'some-path',
|
||||
method: 'POST',
|
||||
body: {
|
||||
extra_param: 123,
|
||||
},
|
||||
omitContextFromBody: true,
|
||||
},
|
||||
manualSteps: ['manual-step'],
|
||||
},
|
||||
};
|
||||
const result = await deprecationsClient.resolveDeprecation(mockDeprecationDetails);
|
||||
|
||||
expect(http.fetch).toBeCalledTimes(1);
|
||||
expect(http.fetch).toBeCalledWith({
|
||||
path: 'some-path',
|
||||
method: 'POST',
|
||||
asSystemRequest: true,
|
||||
body: JSON.stringify({
|
||||
extra_param: 123,
|
||||
}),
|
||||
});
|
||||
expect(result).toEqual({ status: 'ok' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -59,7 +59,7 @@ export class DeprecationsClient {
|
|||
};
|
||||
}
|
||||
|
||||
const { body, method, path } = correctiveActions.api;
|
||||
const { body, method, path, omitContextFromBody = false } = correctiveActions.api;
|
||||
try {
|
||||
await this.http.fetch<void>({
|
||||
path,
|
||||
|
@ -67,7 +67,7 @@ export class DeprecationsClient {
|
|||
asSystemRequest: true,
|
||||
body: JSON.stringify({
|
||||
...body,
|
||||
deprecationDetails: { domainId },
|
||||
...(omitContextFromBody ? {} : { deprecationDetails: { domainId } }),
|
||||
}),
|
||||
});
|
||||
return { status: 'ok' };
|
||||
|
|
|
@ -212,7 +212,7 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations
|
|||
The deprecations API allows plugins to provide an API call that can be used to automatically fix specific deprecations.
|
||||
To do so create a `PUT` or `POST` route in your plugin and specify data you want to be passed in the payload for the deprecation.
|
||||
|
||||
In the example above, `/internal/security/users/test_dashboard_user` will be called when users click on `Quick Resolve` in the UA. The service will automatically pass the body provided in the api corrective action to provide context to the route for fixing the deprecation.
|
||||
In the example above, `/internal/security/users/test_dashboard_user` will be called when users click on `Quick Resolve` in the UA. The service will automatically pass the body provided in the api corrective action to provide context to the route for fixing the deprecation. If you need to omit the deprecation details context in the request of the body, you can use the property `omitContextFromBody`.
|
||||
|
||||
The deprecations service expects a `200` status code to recognize the corrective action as a success.
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ export interface DeprecationsDetails {
|
|||
body?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
/* Allow to omit context in the request of the body */
|
||||
omitContextFromBody?: boolean;
|
||||
};
|
||||
/**
|
||||
* Specify a list of manual steps users need to follow to
|
||||
|
|
|
@ -790,6 +790,7 @@ export interface DeprecationsDetails {
|
|||
body?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
omitContextFromBody?: boolean;
|
||||
};
|
||||
manualSteps: string[];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue