2018-05-29 05:06:30 +02:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2018-11-01 17:41:09 +01:00
|
|
|
import { format as formatUrl } from 'url';
|
2019-02-28 21:06:00 +01:00
|
|
|
import { FtrProviderContext } from '../ftr_provider_context';
|
2018-11-01 17:41:09 +01:00
|
|
|
|
2017-04-12 00:01:06 +02:00
|
|
|
import { EsArchiver } from '../../../src/es_archiver';
|
2019-02-28 21:06:00 +01:00
|
|
|
// @ts-ignore not TS yet
|
2018-08-21 04:30:24 +02:00
|
|
|
import * as KibanaServer from './kibana_server';
|
2017-04-12 00:01:06 +02:00
|
|
|
|
2019-02-28 21:06:00 +01:00
|
|
|
export function EsArchiverProvider({ getService, hasService }: FtrProviderContext): EsArchiver {
|
2017-04-12 00:01:06 +02:00
|
|
|
const config = getService('config');
|
2019-11-20 16:56:23 +01:00
|
|
|
const client = getService('legacyEs');
|
2017-04-12 00:01:06 +02:00
|
|
|
const log = getService('log');
|
|
|
|
|
|
|
|
if (!config.get('esArchiver')) {
|
|
|
|
throw new Error(`esArchiver can't be used unless you specify it's config in your config file`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const dataDir = config.get('esArchiver.directory');
|
|
|
|
|
2018-08-21 04:30:24 +02:00
|
|
|
const esArchiver = new EsArchiver({
|
2017-04-12 00:01:06 +02:00
|
|
|
client,
|
|
|
|
dataDir,
|
|
|
|
log,
|
2019-02-28 21:06:00 +01:00
|
|
|
kibanaUrl: formatUrl(config.get('servers.kibana')),
|
2017-04-12 00:01:06 +02:00
|
|
|
});
|
2018-08-21 04:30:24 +02:00
|
|
|
|
|
|
|
if (hasService('kibanaServer')) {
|
|
|
|
KibanaServer.extendEsArchiver({
|
|
|
|
esArchiver,
|
|
|
|
kibanaServer: getService('kibanaServer'),
|
2019-08-27 23:15:29 +02:00
|
|
|
retry: getService('retry'),
|
2018-08-21 04:30:24 +02:00
|
|
|
defaults: config.get('uiSettings.defaults'),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return esArchiver;
|
2017-04-12 00:01:06 +02:00
|
|
|
}
|