do not use es from setup (#67277)

This commit is contained in:
Mikhail Shustov 2020-05-26 16:09:49 +03:00 committed by GitHub
parent b10bd03734
commit 85bdd940c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 32 deletions

View file

@ -1,21 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { once } from 'lodash';
import { getDataClient } from '../kibana_server_services';
const callWithRequest = once(() => getDataClient());
export const callWithRequestFactory = (request) => {
return (...args) => {
return (
callWithRequest()
.asScoped(request)
// @ts-ignore
.callAsCurrentUser(...args)
);
};
};

View file

@ -4,13 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
let dataClient;
export const setElasticsearchClientServices = (elasticsearch) => {
({ dataClient } = elasticsearch);
};
export const getDataClient = () => dataClient;
let internalRepository;
export const setInternalRepository = (createInternalRepository) => {
internalRepository = createInternalRepository();

View file

@ -5,7 +5,7 @@
*/
import { initRoutes } from './routes/file_upload';
import { setElasticsearchClientServices, setInternalRepository } from './kibana_server_services';
import { setInternalRepository } from './kibana_server_services';
import { registerFileUploadUsageCollector, fileUploadTelemetryMappingsType } from './telemetry';
export class FileUploadPlugin {
@ -15,7 +15,6 @@ export class FileUploadPlugin {
setup(core, plugins) {
core.savedObjects.registerType(fileUploadTelemetryMappingsType);
setElasticsearchClientServices(core.elasticsearch);
this.router = core.http.createRouter();
registerFileUploadUsageCollector(plugins.usageCollection);
}

View file

@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { callWithRequestFactory } from '../client/call_with_request_factory';
import { importDataProvider } from '../models/import_data';
import { updateTelemetry } from '../telemetry/telemetry';
import { MAX_BYTES } from '../../common/constants/file_import';
@ -86,7 +85,7 @@ const finishValidationAndProcessReq = () => {
let resp;
try {
const validIdReqData = idConditionalValidation(body, boolHasId);
const callWithRequest = callWithRequestFactory(req);
const callWithRequest = con.core.elasticsearch.dataClient.callAsCurrentUser;
const { importData: importDataFunc } = importDataProvider(callWithRequest);
const { index, settings, mappings, ingestPipeline, data } = validIdReqData;