From f8b94f1fae750d7b0ad48bf552c65ce82afd341c Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 May 2020 08:10:42 +0200 Subject: [PATCH 1/2] dump prettier version to v2 --- packages/kbn-spec-to-console/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-spec-to-console/package.json b/packages/kbn-spec-to-console/package.json index ebbf244eb2e101..303e5e551ff264 100644 --- a/packages/kbn-spec-to-console/package.json +++ b/packages/kbn-spec-to-console/package.json @@ -24,4 +24,4 @@ "commander": "^3.0.0", "glob": "^7.1.2" } -} \ No newline at end of file +} From 36a0e9c89924292955e24b13e4262e2f98b0bd58 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 May 2020 15:07:53 +0200 Subject: [PATCH 2/2] do not use es from setup --- .../client/call_with_request_factory.js | 21 ------------------- .../server/kibana_server_services.js | 7 ------- x-pack/plugins/file_upload/server/plugin.js | 3 +-- .../file_upload/server/routes/file_upload.js | 3 +-- 4 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 x-pack/plugins/file_upload/server/client/call_with_request_factory.js diff --git a/x-pack/plugins/file_upload/server/client/call_with_request_factory.js b/x-pack/plugins/file_upload/server/client/call_with_request_factory.js deleted file mode 100644 index 3ff19a5b8f84dd..00000000000000 --- a/x-pack/plugins/file_upload/server/client/call_with_request_factory.js +++ /dev/null @@ -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) - ); - }; -}; diff --git a/x-pack/plugins/file_upload/server/kibana_server_services.js b/x-pack/plugins/file_upload/server/kibana_server_services.js index 880ea5caf31d3b..703b55543fe075 100644 --- a/x-pack/plugins/file_upload/server/kibana_server_services.js +++ b/x-pack/plugins/file_upload/server/kibana_server_services.js @@ -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(); diff --git a/x-pack/plugins/file_upload/server/plugin.js b/x-pack/plugins/file_upload/server/plugin.js index a11516d03f0683..08dd8762ab49d2 100644 --- a/x-pack/plugins/file_upload/server/plugin.js +++ b/x-pack/plugins/file_upload/server/plugin.js @@ -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); } diff --git a/x-pack/plugins/file_upload/server/routes/file_upload.js b/x-pack/plugins/file_upload/server/routes/file_upload.js index cd5ccc57075a34..c7f3e2a6211619 100644 --- a/x-pack/plugins/file_upload/server/routes/file_upload.js +++ b/x-pack/plugins/file_upload/server/routes/file_upload.js @@ -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;