mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
This commit is contained in:
parent
10983d5926
commit
f06a5051de
3 changed files with 31 additions and 4 deletions
|
@ -73,7 +73,7 @@ exports.Artifact = class Artifact {
|
|||
* @param {string} version
|
||||
* @param {ToolingLog} log
|
||||
*/
|
||||
static async get(license, version, log) {
|
||||
static async getSnapshot(license, version, log) {
|
||||
const urlVersion = `${encodeURIComponent(version)}-SNAPSHOT`;
|
||||
const urlBuild = encodeURIComponent(TEST_ES_SNAPSHOT_VERSION);
|
||||
const url = `${V1_VERSIONS_API}/${urlVersion}/builds/${urlBuild}/projects/elasticsearch`;
|
||||
|
@ -138,6 +138,24 @@ exports.Artifact = class Artifact {
|
|||
return new Artifact(artifactSpec, log);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch an Artifact from the Elasticsearch past releases url
|
||||
* @param {string} url
|
||||
* @param {ToolingLog} log
|
||||
*/
|
||||
static async getArchive(url, log) {
|
||||
const shaUrl = `${url}.sha512`;
|
||||
|
||||
const artifactSpec = {
|
||||
url: url,
|
||||
filename: path.basename(url),
|
||||
checksumUrl: shaUrl,
|
||||
checksumType: getChecksumType(shaUrl),
|
||||
};
|
||||
|
||||
return new Artifact(artifactSpec, log);
|
||||
}
|
||||
|
||||
constructor(spec, log) {
|
||||
this._spec = spec;
|
||||
this._log = log;
|
||||
|
|
|
@ -22,8 +22,10 @@ const path = require('path');
|
|||
const chalk = require('chalk');
|
||||
const execa = require('execa');
|
||||
const del = require('del');
|
||||
const url = require('url');
|
||||
const { log: defaultLog, decompress } = require('../utils');
|
||||
const { BASE_PATH, ES_CONFIG, ES_KEYSTORE_BIN } = require('../paths');
|
||||
const { Artifact } = require('../artifact');
|
||||
|
||||
/**
|
||||
* Extracts an ES archive and optionally installs plugins
|
||||
|
@ -44,13 +46,20 @@ exports.installArchive = async function installArchive(archive, options = {}) {
|
|||
log = defaultLog,
|
||||
} = options;
|
||||
|
||||
let dest = archive;
|
||||
if (['http:', 'https:'].includes(url.parse(archive).protocol)) {
|
||||
const artifact = await Artifact.getArchive(archive, log);
|
||||
dest = path.resolve(basePath, 'cache', artifact.getFilename());
|
||||
await artifact.download(dest);
|
||||
}
|
||||
|
||||
if (fs.existsSync(installPath)) {
|
||||
log.info('install directory already exists, removing');
|
||||
await del(installPath, { force: true });
|
||||
}
|
||||
|
||||
log.info('extracting %s', chalk.bold(archive));
|
||||
await decompress(archive, installPath);
|
||||
log.info('extracting %s', chalk.bold(dest));
|
||||
await decompress(dest, installPath);
|
||||
log.info('extracted to %s', chalk.bold(installPath));
|
||||
|
||||
if (license === 'trial') {
|
||||
|
|
|
@ -45,7 +45,7 @@ exports.downloadSnapshot = async function installSnapshot({
|
|||
log.info('install path: %s', chalk.bold(installPath));
|
||||
log.info('license: %s', chalk.bold(license));
|
||||
|
||||
const artifact = await Artifact.get(license, version, log);
|
||||
const artifact = await Artifact.getSnapshot(license, version, log);
|
||||
const dest = path.resolve(basePath, 'cache', artifact.getFilename());
|
||||
await artifact.download(dest);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue