Change ContextContainer to lazily initialize providers (#129896)

* Change ContextContainer to lazily initialize providers

* Introduce CustomRequestHandlerContext, start adapting usages

* adapt IContextProvider's return type

* start fixing violations

* fixing violations - 2

* adapt home routes

* fix remaining core violation

* fix violations on core tests

* fixing more violations

* fixing more violations

* update generated doc...

* fix more violations

* adapt remaining RequestHandlerContext

* fix more violations

* fix non-async method

* more fixes

* fix another await in non async method

* add yet another missing async

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

* add yet yet another missing async

* update fleet's endpoints

* fix telemetry endpoints

* fix event_log endpoints

* fix some security unit tests

* adapt canvas routes

* adapt alerting routes

* adapt more so_tagging routes

* fix data_enhanced routes

* fix license_management routes

* fix file_upload routes

* fix index_management routes

* fix lists routes

* fix snapshot_restore routes

* fix rule_registry routes

* fix ingest_pipelines routes

* fix remote_clusters routes

* fix index_lifecycle_management routes

* improve and fix the lazy implementation

* fix triggers_actions_ui endpoints

* start fixing unit tests

* fix cases routes

* fix transform routes

* fix upgrade_assistant routes

* fix uptime route wrapper

* fix uptime route wrapper bis

* update osquery routes

* update cross_cluster_replication routes

* fix some ML routes / wrappers

* adapt maps routes

* adapt rollup routes

* fix some canvas unit tests

* fix more canvas unit tests

* fix observability wrapper

* fix (?) infra type hell

* start fixing monitoring

* fix a few test plugins

* woups

* fix yet more violations

* fixing UA  tests

* fix logstash handlers

* fix fleet unit tests

* lint?

* one more batch

* update security_solution endpoints

* start fixing security_solution mocks

* start fixing security_solution tests

* fix more security_solution tests

* fix more security_solution tests

* just one more

* fix last (?) security_solution tests

* fix timelion javascript file

* fix more test plugins

* fix transforms context type

* fix ml context type

* fix context tests

* fix securitySolution withEndpointAuthz tests

* fix features unit tests

* fix actions unit tests

* fix imports

* fix duplicate import

* fix some merge problems

* fix new usage

* fix new test

* introduces context.resolve

* down the rabbit hole again

* start fixing test type failures

* more test type failures fixes

* move import comment back to correct place

* more test type failures fixes, bis

* use context.resolve for security solution rules routes

* fix new violations due to master merge

* remove comment

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Pierre Gayvallet 2022-04-22 13:15:58 +02:00 committed by GitHub
parent 706d9268ef
commit a02c00b8a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
699 changed files with 4508 additions and 3170 deletions

View file

@ -136,7 +136,8 @@ async function fetchFieldExistence({
});
}
const metaFields: string[] = await context.core.uiSettings.client.get(UI_SETTINGS.META_FIELDS);
const uiSettingsClient = (await context.core).uiSettings.client;
const metaFields: string[] = await uiSettingsClient.get(UI_SETTINGS.META_FIELDS);
const dataView = await dataViewsService.get(indexPatternId);
const allFields = buildFieldList(dataView, metaFields);
const existingFieldList = await dataViewsService.getFieldsForIndexPattern(dataView, {
@ -169,7 +170,8 @@ async function legacyFetchFieldExistenceSampling({
timeFieldName?: string;
includeFrozen: boolean;
}) {
const metaFields: string[] = await context.core.uiSettings.client.get(UI_SETTINGS.META_FIELDS);
const coreContext = await context.core;
const metaFields: string[] = await coreContext.uiSettings.client.get(UI_SETTINGS.META_FIELDS);
const indexPattern = await dataViewsService.get(indexPatternId);
const fields = buildFieldList(indexPattern, metaFields);
@ -179,7 +181,7 @@ async function legacyFetchFieldExistenceSampling({
fromDate,
toDate,
dslQuery,
client: context.core.elasticsearch.client.asCurrentUser,
client: coreContext.elasticsearch.client.asCurrentUser,
index: indexPattern.title,
timeFieldName: timeFieldName || indexPattern.timeFieldName,
fields,

View file

@ -39,7 +39,7 @@ export async function initFieldsRoute(setup: CoreSetup<PluginStartContract>) {
},
},
async (context, req, res) => {
const requestClient = context.core.elasticsearch.client.asCurrentUser;
const requestClient = (await context.core).elasticsearch.client.asCurrentUser;
const { fromDate, toDate, fieldName, dslQuery, size } = req.body;
const [{ savedObjects, elasticsearch }, { dataViews }] = await setup.getStartServices();

View file

@ -33,7 +33,7 @@ export async function initLensUsageRoute(setup: CoreSetup<PluginStartContract>)
const { events, suggestionEvents } = req.body;
try {
const client = context.core.savedObjects.client;
const client = (await context.core).savedObjects.client;
const allEvents: Array<{
type: 'lens-ui-telemetry';